Work on moving entity table into sessions.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5472 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2001-10-08 07:14:58 +00:00
parent 834c6fea7b
commit b8d2150e4b
13 changed files with 73 additions and 25 deletions

View File

@@ -2869,6 +2869,7 @@ txn_restore_guid_end_handler(gpointer data_for_children,
gpointer parent_data, gpointer global_data,
gpointer *result, const gchar *tag)
{
GNCParseStatus *pstatus = (GNCParseStatus *) global_data;
Transaction *t = (Transaction *) parent_data;
gchar *txt = NULL;
GUID gid;
@@ -2884,7 +2885,7 @@ txn_restore_guid_end_handler(gpointer data_for_children,
g_return_val_if_fail(ok, FALSE);
if(xaccTransLookup(&gid)) {
if(xaccTransLookup(&gid, pstatus->session)) {
return(FALSE);
}

View File

@@ -307,7 +307,7 @@ query_cb (PGBackend *be, PGresult *result, int j, gpointer data)
/* use markers to avoid redundant traversals of transactions we've
* already checked recently. */
trans = xaccTransLookup (&trans_guid);
trans = xaccTransLookup (&trans_guid, be->session);
if (NULL != trans)
{
if (0 != trans->marker)

View File

@@ -321,7 +321,8 @@ pgendProcessEvents (Backend *bend)
pgendCopyTransactionToEngine (be, &(ev->guid));
break;
case GNC_EVENT_DESTROY: {
Transaction *trans = xaccTransLookup (&(ev->guid));
Transaction *trans = xaccTransLookup (&(ev->guid),
be->session);
xaccTransBeginEdit (trans);
xaccTransDestroy (trans);
xaccTransCommitEdit (trans);

View File

@@ -527,7 +527,7 @@ pgendCopyTransactionToEngine (PGBackend *be, const GUID *trans_guid)
pgendDisable(be);
/* first, see if we already have such a transaction */
trans = xaccTransLookup (trans_guid);
trans = xaccTransLookup (trans_guid, be->session);
if (!trans)
{
trans = xaccMallocTransaction(be->session);

View File

@@ -67,7 +67,7 @@ get_mass_trans_cb (PGBackend *be, PGresult *result, int j, gpointer data)
/* first, see if we already have such a transaction */
string_to_guid (DB_GET_VAL("transGUID",j), &trans_guid);
trans = xaccTransLookup (&trans_guid);
trans = xaccTransLookup (&trans_guid, be->session);
if (trans)
{
/* If transaction already exists, determine whose data is
@@ -157,7 +157,7 @@ get_mass_entry_cb (PGBackend *be, PGresult *result, int j, gpointer data)
guid = nullguid; /* just in case the read fails ... */
string_to_guid (DB_GET_VAL("transGUID",j), &guid);
trans = xaccTransLookup (&guid);
trans = xaccTransLookup (&guid, be->session);
if (!trans)
{
PERR ("trans not found, will delete this split\n"

View File

@@ -2378,7 +2378,8 @@ xaccGUIDMatchPredicate(Split * s, PredicateData * pd)
xaccAccountLookupEntityTable (guid, s->entity_table));
case GNC_ID_TRANS:
return xaccSplitGetParent (s) == xaccTransLookup (guid);
return (xaccSplitGetParent (s) ==
xaccTransLookupEntityTable (guid, s->entity_table));
case GNC_ID_SPLIT:
return s == xaccSplitLookup (guid);

View File

@@ -886,10 +886,20 @@ xaccTransSetGUID (Transaction *trans, const GUID *guid)
\********************************************************************/
Transaction *
xaccTransLookup (const GUID *guid)
xaccTransLookupEntityTable (const GUID *guid,
GNCEntityTable *entity_table)
{
/* FIXME: uncomment when entity tables are in sessions */
/* g_return_val_if_fail (entity_table, NULL); */
return xaccLookupEntity (guid, GNC_ID_TRANS);
}
Transaction *
xaccTransLookup (const GUID *guid, GNCSession *session)
{
if (!guid) return NULL;
return xaccLookupEntity(guid, GNC_ID_TRANS);
g_return_val_if_fail (session, NULL);
return xaccLookupEntity (guid, GNC_ID_TRANS);
}
/********************************************************************\

View File

@@ -130,7 +130,7 @@ gboolean xaccTransIsOpen (Transaction *trans);
*/
const GUID * xaccTransGetGUID (Transaction *trans);
GUID xaccTransReturnGUID (Transaction *trans);
Transaction * xaccTransLookup (const GUID *guid);
Transaction * xaccTransLookup (const GUID *guid, GNCSession *session);
/* Transaction slots are used to store arbitrary strings, numbers, and

View File

@@ -201,6 +201,10 @@ struct transaction_s
guint32 idata; /* used by the sql backend for kvp management */
};
/* Lookup the transaction with the guid, using the given table. */
Transaction * xaccTransLookupEntityTable (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

@@ -230,7 +230,7 @@ gnc_html_register_url_cb (const char *location, const char *label,
break;
case GNC_ID_TRANS:
trans = xaccTransLookup (&guid);
trans = xaccTransLookup (&guid, gnc_get_current_session ());
split = NULL;
for (node = xaccTransGetSplitList (trans); node; node = node->next)

View File

@@ -196,7 +196,8 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
return;
info = gnc_split_register_get_info (reg);
pending_trans = xaccTransLookup (&info->pending_trans_guid);
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
PINFO ("start callback %d %d \n",
new_virt_loc.vcell_loc.virt_row,
@@ -545,7 +546,7 @@ gnc_split_register_auto_completion (SplitRegister *reg,
VirtualLocation *p_new_virt_loc)
{
SRInfo *info = gnc_split_register_get_info (reg);
Transaction *pending_trans = xaccTransLookup (&info->pending_trans_guid);
Transaction *pending_trans;
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *blank_trans = xaccSplitGetParent (blank_split);
VirtualLocation new_virt_loc;
@@ -556,6 +557,9 @@ gnc_split_register_auto_completion (SplitRegister *reg,
BasicCell *cell;
Split *split;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
/* auto-completion is only triggered by a tab out */
if (dir != GNC_TABLE_TRAVERSE_RIGHT)
return FALSE;
@@ -844,7 +848,8 @@ gnc_split_register_traverse (VirtualLocation *p_new_virt_loc,
if (info->first_pass)
return FALSE;
pending_trans = xaccTransLookup (&info->pending_trans_guid);
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
virt_loc = *p_new_virt_loc;
info->exact_traversal = (dir == GNC_TABLE_TRAVERSE_POINTER);

View File

@@ -136,7 +136,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
{
SRInfo *info = gnc_split_register_get_info (reg);
Split *blank_split = xaccSplitLookup (&info->blank_split_guid);
Transaction *pending_trans = xaccTransLookup (&info->pending_trans_guid);
Transaction *pending_trans;
CursorBuffer *cursor_buffer;
GHashTable *trans_table = NULL;
CellBlock *cursor_header;
@@ -167,6 +167,9 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
int new_split_row = -1;
time_t present;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
/* make sure we have a blank split */
if (blank_split == NULL)
{

View File

@@ -880,11 +880,14 @@ 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 = xaccTransLookup (&info->pending_trans_guid);
Transaction *pending_trans;
Transaction *trans;
Account *account;
Split *split;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
/* get the current split based on cursor position */
split = gnc_split_register_get_current_split (reg);
if (split == NULL)
@@ -929,11 +932,14 @@ 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 = xaccTransLookup (&info->pending_trans_guid);
Transaction *pending_trans;
Transaction *trans;
Account *account;
Split *split;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
/* get the current split based on cursor position */
split = gnc_split_register_get_current_split (reg);
if (split == NULL)
@@ -996,13 +1002,16 @@ 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 = xaccTransLookup (&info->pending_trans_guid);
Transaction *pending_trans;
Transaction *trans;
Account *account;
GList *splits;
GList *node;
Split *split;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
/* get the current split based on cursor position */
split = gnc_split_register_get_current_split (reg);
if (split == NULL)
@@ -1086,13 +1095,16 @@ gnc_split_register_cancel_cursor_split_changes (SplitRegister *reg)
void
gnc_split_register_cancel_cursor_trans_changes (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info(reg);
Transaction *pending_trans = xaccTransLookup(&info->pending_trans_guid);
SRInfo *info = gnc_split_register_get_info (reg);
Transaction *pending_trans;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
/* Get the currently open transaction, rollback the edits on it, and
* then repaint everything. To repaint everything, make a note of
* all of the accounts that will be affected by this rollback. */
if (!xaccTransIsOpen(pending_trans))
if (!xaccTransIsOpen (pending_trans))
{
gnc_split_register_cancel_cursor_split_changes (reg);
return;
@@ -1309,13 +1321,18 @@ 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 = xaccTransLookup (&info->pending_trans_guid);
Transaction *blank_trans = xaccSplitGetParent (blank_split);
Transaction *pending_trans;
Transaction *blank_trans;
Transaction *trans;
const char *memo;
const char *desc;
Split *split;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
blank_trans = xaccSplitGetParent (blank_split);
/* get the handle to the current split and transaction */
split = gnc_split_register_get_current_split (reg);
trans = gnc_split_register_get_current_trans (reg);
@@ -1847,7 +1864,10 @@ gboolean
gnc_split_register_changed (SplitRegister *reg)
{
SRInfo *info = gnc_split_register_get_info (reg);
Transaction *pending_trans = xaccTransLookup (&info->pending_trans_guid);
Transaction *pending_trans;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
if (reg == NULL)
return FALSE;
@@ -2187,9 +2207,12 @@ 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 = xaccTransLookup (&info->pending_trans_guid);
Transaction *pending_trans;
Transaction *trans;
pending_trans = xaccTransLookup (&info->pending_trans_guid,
gnc_get_current_session ());
gnc_suspend_gui_refresh ();
/* be sure to destroy the "blank split" */