Phil Longstaff <[EMAIL PROTECTED]> writes:

> 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.

I have no idea why qofTransSetNum() exists.  That logic certainly
looks wrong to me.  Even worse, the qof version will crash if you
pass in a NULL trans!  Eww.

> Phil

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       [EMAIL PROTECTED]                        PGP key available
_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to