AUDIT: r17868 - gnucash/trunk/src/backend/file - Bug #569735: Don't create a new nested template root account when a file is opened

Christian Stimming cstim at
Sat Jan 31 14:50:09 EST 2009

Author: cstim
Date: 2009-01-31 14:50:08 -0500 (Sat, 31 Jan 2009)
New Revision: 17868

Bug #569735: Don't create a new nested template root account when a file is opened

Whenever an XML file is opened, Gnucash creates a new template root account and
makes the old one a child of it.  My main accounts file had them nested over
540 deep before I got annoyed enough to fix this.  The problem is that
sxtg_book_begin creates a root account when the book is opened.  Then
add_template_transaction_local tries to replace this new root account with the
one read from the file.  However the code that does this is rather badly broken
and the result is that the one read from the file becomes a child of the one
created in sxtg_book_begin.

This patch avoids creating any more nested root accounts, but it doesn't get
rid of the ones that are already there.  This is slightly more tricky than just
deleting them since, although most of them have no children (other than the
next root account), some do.  Accounts created for template transactions will
be children of whatever root account happens to be at the top of the tree then.
 As the file is saved and reopened, this will get pushed down into the tree of
accounts.  In my case about 5 of the 540 or so root accounts had other

Patch by Mike Alexander.

More information about the gnucash-patches mailing list