Transaction API question

Charles Day cedayiv at gmail.com
Thu Feb 12 00:53:27 EST 2009


On Tue, Feb 10, 2009 at 12:27 PM, Alan Jenkins
<alan-jenkins at tuffmail.co.uk>wrote:

> Christian Stimming wrote:
> > Am Dienstag, 10. Februar 2009 11:02 schrieb Alan Jenkins:
> >
> >>>> I have a question about how to destroy a transaction properly.
> >>>>
> >> Interesting.  The generic import layer does this:
> >>
> >> xaccTransDestroy(trans);
> >> xaccTransCommitEdit(trans);
> >>
> >> to destroy an open transaction in gnc_import_exists_online_id().  It
> >> seems to work :-).  Maybe the register code is missing the commit.
> >>
> >
> > I really don't know now, and I also didn't really know at the time when I
> > wrote (part of) the importing code. I vaguely recall this Destroy/Commit
> > sequence had to be used there because otherwise the transactions didn't
> > disappear as intended. However, even at that time I couldn't find out
> which
> > one was the intended way, and it was sufficient for me to see this work.
> >
>
> The comments actually say this is the right way
>
> /**
>  The xaccTransDestroy() method will remove all
>  of the splits from each of their accounts, free the memory
>  associated with them.  This routine must be followed by either
>  an xaccTransCommitEdit(), in which case the transaction
>  memory will be freed, or by xaccTransRollbackEdit(), in which
>  case nothing at all is freed, and everything is put back into
>  original order. */
>

I've committed r17896, which updates these comments to make it (hopefully)
clear that no extra commit step is required of the caller if the transaction
isn't already open.

Also, I've committed r17895 to fix the way the register was trying to
destroy blank transactions.


> Regards
> Alan
>

Cheers,
Charles


More information about the gnucash-devel mailing list