[Gnucash-changes] r13130 - gnucash/trunk/src/engine - Replace check_open() in setter API with internal qof_{begin, commit}_edit().

Derek Atkins warlord at MIT.EDU
Thu Feb 9 12:12:13 EST 2006


Chris,

Chris Shoemaker <chris at cvs.gnucash.org> writes:

> Log:
>    Replace check_open() in setter API with internal qof_{begin,commit}_edit().
>
>
> Modified: gnucash/trunk/src/engine/Transaction.c
> ===================================================================
> --- gnucash/trunk/src/engine/Transaction.c	2006-02-06 06:45:25 UTC (rev 13129)
> +++ gnucash/trunk/src/engine/Transaction.c	2006-02-06 16:18:52 UTC (rev 13130)
> @@ -1626,7 +1626,7 @@
>    gint fraction, old_fraction;
>  
>    if (!trans || !curr || trans->common_currency == curr) return;
> -  check_open (trans);
> +  qof_begin_edit(QOF_INSTANCE(trans));

I think you want to be using xaccTrans{Begin,Commit}Edit here, and not
qof_{begin,commit}_edit.  The resaon is clear in a moment...

[snip]
> -  trans->inst.do_free = TRUE;
> +  if (!xaccTransGetReadOnly (trans) || 
> +      qof_book_shutting_down(trans->inst.book)) {
> +      qof_begin_edit(QOF_INSTANCE(trans));
> +      trans->inst.do_free = TRUE;
> +      qof_commit_edit(QOF_INSTANCE(trans));
> +  }

qof_commit_edit() knows nothing about inst.do_free.  The do_free is
only handled by the object's Begin/Commit edit API, not by the lower
level QOF begin/commit edit API.   So this can lead to a memory leak.

Also, by calling the qof command directly you've now made it such
that you could lose transaction log information.  The log is written
out in xaccTrans{Begin,Commit}Edit so by bypassing that you lose
logging info.

-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
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list