GDA: Question about some engine transaction functions

Phil Longstaff plongstaff at rogers.com
Sun Mar 30 21:19:21 EDT 2008


src/engine/Transaction.c has the following functions:

static void
qofTransSetNum (Transaction *trans, const char *xnum)
{
        if (!qof_begin_edit(&trans->inst)) return;
        xaccTransSetNum(trans, xnum);
        qof_commit_edit(&trans->inst);
}
	
void
xaccTransSetNum (Transaction *trans, const char *xnum)
{
   if (!trans || !xnum) return;
   xaccTransBeginEdit(trans);
	
   CACHE_REPLACE(trans->num, xnum);
   qof_instance_set_dirty(QOF_INSTANCE(trans));
   mark_trans(trans);  /* Dirty balance of every account in trans */
   xaccTransCommitEdit(trans);
}


qofTransSetNum() is the function which is registered with qof, and if
there is a function registered with qof, the gda backend tries to use
it.  The problem is that if the editlevel is not 0 (which it is, because
the gda backend calls xaccTransBeginEdit() before the tx is loaded from
the db and xaccTransCommitEdit() after it is loaded), qof_begin_edit()
will return FALSE so that the routine does nothing, but does leave the
editlevel incremented.

Is this correct behaviour?  If so, it is not useful to me.  Note that
there are a number of these pairs of routine in Transaction.c and there
may be more in other files.

Phil



More information about the gnucash-devel mailing list