Transaction API question

Charles Day cedayiv at gmail.com
Tue Feb 10 17:39:34 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. */
>

Interesting, as xaccTransDestroy() itself includes an open/commit pair
(either itself or via functions it calls -- can't remember at the moment).


>
> Regards
> Alan
>


More information about the gnucash-devel mailing list