Work on moving entity tables into sessions.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5473 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-10-08 22:48:37 +00:00
parent b8d2150e4b
commit d384066697
14 changed files with 82 additions and 29 deletions

View File

@ -3178,6 +3178,7 @@ txn_restore_split_guid_end_handler(gpointer data_for_children,
gpointer parent_data, gpointer global_data,
gpointer *result, const gchar *tag)
{
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
Split *s = (Split *) parent_data;
gchar *txt = NULL;
GUID gid;
@ -3193,7 +3194,7 @@ txn_restore_split_guid_end_handler(gpointer data_for_children,
g_return_val_if_fail(ok, FALSE);
if(xaccSplitLookup(&gid)) {
if(xaccSplitLookup(&gid, pstatus->session)) {
return(FALSE);
}

View File

@ -106,7 +106,7 @@ delete_list_cb (PGBackend *be, PGresult *result, int j, gpointer data)
string_to_guid (DB_GET_VAL ("entryGuid", j), &guid);
/* If the database has splits that the engine doesn't,
* collect 'em up & we'll have to delete em */
if (NULL == xaccSplitLookup (&guid))
if (NULL == xaccSplitLookup (&guid, be->session))
{
deletelist = g_list_prepend (deletelist,
g_strdup(DB_GET_VAL ("entryGuid", j)));
@ -150,7 +150,7 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
Split *s;
GUID guid;
string_to_guid ((char *)(node->data), &guid);
s = xaccSplitLookup(&guid);
s = xaccSplitLookup(&guid, be->session);
pgendStoreAuditSplit (be, s, SQL_DELETE);
p = stpcpy (p, "DELETE FROM gncEntry WHERE entryGuid='");
@ -169,7 +169,7 @@ pgendStoreTransactionNoLock (PGBackend *be, Transaction *trans,
Split *s;
GUID guid;
string_to_guid ((char *)(node->data), &guid);
s = xaccSplitLookup(&guid);
s = xaccSplitLookup(&guid, be->session);
pgendKVPDelete (be, s->idata);
g_free (node->data);
}
@ -404,7 +404,7 @@ pgendCopySplitsToEngine (PGBackend *be, Transaction *trans)
PINFO ("split GUID=%s", DB_GET_VAL("entryGUID",j));
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("entryGUID",j), &guid);
s = xaccSplitLookup (&guid);
s = xaccSplitLookup (&guid, be->session);
if (!s)
{
s = xaccMallocSplit(be->session);

View File

@ -138,7 +138,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
PINFO ("split GUID=%s", DB_GET_VAL("entryGUID",j));
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("entryGUID",j), &guid);
s = xaccSplitLookup (&guid);
s = xaccSplitLookup (&guid, be->session);
if (!s)
{
s = xaccMallocSplit(be->session);

View File

@ -2382,7 +2382,7 @@ xaccGUIDMatchPredicate(Split * s, PredicateData * pd)
xaccTransLookupEntityTable (guid, s->entity_table));
case GNC_ID_SPLIT:
return s == xaccSplitLookup (guid);
return s == xaccSplitLookupEntityTable (guid, s->entity_table);
}
}

View File

@ -370,9 +370,19 @@ xaccSplitSetGUID (Split *split, const GUID *guid)
\********************************************************************/
Split *
xaccSplitLookup (const GUID *guid)
xaccSplitLookupEntityTable (const GUID *guid, GNCEntityTable *entity_table)
{
if (!guid) return NULL;
/* FIXME: uncomment soon */
/* g_return_val_if_fail (entity_table, NULL); */
return xaccLookupEntity(guid, GNC_ID_SPLIT);
}
Split *
xaccSplitLookup (const GUID *guid, GNCSession *session)
{
if (!guid) return NULL;
g_return_val_if_fail (session, NULL);
return xaccLookupEntity(guid, GNC_ID_SPLIT);
}

View File

@ -268,7 +268,7 @@ void xaccSplitSetSlots_nc(Split *s, kvp_frame *frm);
*/
const GUID * xaccSplitGetGUID (Split *split);
GUID xaccSplitReturnGUID (Split *split);
Split * xaccSplitLookup (const GUID *guid);
Split * xaccSplitLookup (const GUID *guid, GNCSession *session);
/* The memo is an arbitrary string associated with a split.
* Users typically type in free form text from the GUI.

View File

@ -201,10 +201,13 @@ struct transaction_s
guint32 idata; /* used by the sql backend for kvp management */
};
/* Lookup the transaction with the guid, using the given table. */
/* Lookup the transaction/split with the guid, using the given table. */
Transaction * xaccTransLookupEntityTable (const GUID *guid,
GNCEntityTable *entity_table);
Split * xaccSplitLookupEntityTable (const GUID *guid,
GNCEntityTable *entity_table);
/* Set the transaction's GUID. This should only be done when reading
* a transaction from a datafile, or some other external source. Never
* call this on an existing transaction! */

View File

@ -251,7 +251,7 @@ gnc_html_register_url_cb (const char *location, const char *label,
break;
case GNC_ID_SPLIT:
split = xaccSplitLookup (&guid);
split = xaccSplitLookup (&guid, gnc_get_current_session ());
if (!split)
{
result->error_message = g_strdup_printf (_("No such split: %s"),

View File

@ -546,17 +546,21 @@ gnc_split_register_auto_completion (SplitRegister *reg,
VirtualLocation *p_new_virt_loc)
{
SRInfo *info = gnc_split_register_get_info (reg);
Transaction *pending_trans;
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *blank_trans = xaccSplitGetParent (blank_split);
VirtualLocation new_virt_loc;
CursorClass cursor_class;
Transaction *pending_trans;
Transaction *blank_trans;
const char *cell_name;
Transaction *trans;
Split *blank_split;
gnc_numeric amount;
BasicCell *cell;
Split *split;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
blank_trans = xaccSplitGetParent (blank_split);
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());

View File

@ -135,7 +135,6 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
Account *default_account)
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *pending_trans;
CursorBuffer *cursor_buffer;
GHashTable *trans_table = NULL;
@ -147,6 +146,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
Transaction *trans;
CursorClass find_class;
Split *find_trans_split;
Split *blank_split;
Split *find_split;
Split *split;
Table *table;
@ -167,6 +167,9 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
int new_split_row = -1;
time_t present;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());

View File

@ -97,7 +97,8 @@ gnc_split_register_save_cells (gpointer save_data,
if (gnc_num_cell_set_last_num ((NumCell *) cell, value))
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid,
gnc_get_current_session ());
Transaction *blank_trans = xaccSplitGetParent (blank_split);
if (trans != blank_trans)

View File

@ -848,7 +848,8 @@ gnc_split_register_get_balance_entry (VirtualLocation virt_loc,
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
if (split == xaccSplitLookup (&info->blank_split_guid))
if (split == xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ()))
return NULL;
is_trans = gnc_cell_name_equal

View File

@ -119,7 +119,7 @@ gnc_split_register_get_split (SplitRegister *reg,
if (guid == NULL)
return NULL;
return xaccSplitLookup (guid);
return xaccSplitLookup (guid, gnc_get_current_session ());
}
Account *

View File

@ -362,7 +362,7 @@ gnc_split_register_get_blank_split (SplitRegister *reg)
if (!reg) return NULL;
return xaccSplitLookup (&info->blank_split_guid);
return xaccSplitLookup (&info->blank_split_guid, gnc_get_current_session ());
}
gboolean
@ -395,7 +395,7 @@ gnc_split_register_get_split_virt_loc (SplitRegister *reg, Split *split,
if (!vcell->visible)
continue;
s = xaccSplitLookup (vcell->vcell_data);
s = xaccSplitLookup (vcell->vcell_data, gnc_get_current_session ());
if (s == split)
{
@ -451,14 +451,16 @@ Split *
gnc_split_register_duplicate_current (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
CursorClass cursor_class;
Transaction *trans;
Split *return_split;
Split *trans_split;
Split *blank_split;
gboolean changed;
Split *split;
blank_split = xaccSplitLookup(&info->blank_split_guid,
gnc_get_current_session ());
split = gnc_split_register_get_current_split (reg);
trans = gnc_split_register_get_current_trans (reg);
trans_split = gnc_split_register_get_current_trans_split (reg, NULL);
@ -616,13 +618,15 @@ gnc_split_register_copy_current_internal (SplitRegister *reg,
gboolean use_cut_semantics)
{
SRInfo *info = gnc_split_register_get_info(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
CursorClass cursor_class;
Transaction *trans;
Split *blank_split;
gboolean changed;
Split *split;
SCM new_item;
blank_split = xaccSplitLookup(&info->blank_split_guid,
gnc_get_current_session ());
split = gnc_split_register_get_current_split (reg);
trans = gnc_split_register_get_current_trans (reg);
@ -711,12 +715,14 @@ void
gnc_split_register_cut_current (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
CursorClass cursor_class;
Transaction *trans;
Split *blank_split;
gboolean changed;
Split *split;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
split = gnc_split_register_get_current_split (reg);
trans = gnc_split_register_get_current_trans (reg);
@ -752,15 +758,17 @@ void
gnc_split_register_paste_current (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info(reg);
Split *blank_split = xaccSplitLookup(&info->blank_split_guid);
CursorClass cursor_class;
Transaction *trans;
Split *blank_split;
Split *trans_split;
Split *split;
if (copied_class == CURSOR_CLASS_NONE)
return;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
split = gnc_split_register_get_current_split (reg);
trans = gnc_split_register_get_current_trans (reg);
@ -879,12 +887,17 @@ void
gnc_split_register_delete_current_split (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *pending_trans;
Transaction *trans;
Split *blank_split;
Account *account;
Split *split;
if (!reg) return;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
@ -931,12 +944,16 @@ void
gnc_split_register_delete_current_trans (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *pending_trans;
Transaction *trans;
Split *blank_split;
Account *account;
Split *split;
if (!reg) return;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
@ -1001,14 +1018,19 @@ void
gnc_split_register_emtpy_current_trans (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *pending_trans;
Transaction *trans;
Split *blank_split;
Account *account;
GList *splits;
GList *node;
Split *split;
if (!reg) return;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
@ -1320,14 +1342,19 @@ gboolean
gnc_split_register_save (SplitRegister *reg, gboolean do_commit)
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *pending_trans;
Transaction *blank_trans;
Transaction *trans;
Split *blank_split;
const char *memo;
const char *desc;
Split *split;
if (!reg) return FALSE;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
@ -2206,9 +2233,12 @@ static void
gnc_split_register_cleanup (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *pending_trans;
Transaction *trans;
Split *blank_split;
blank_split = xaccSplitLookup (&info->blank_split_guid,
gnc_get_current_session ());
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());