r19559 - gnucash/trunk/src/backend/xml - Fix bug 573702. When reading an old data file that doesn't have a template root

Mike Alexander mta at code.gnucash.org
Mon Sep 6 21:14:25 EDT 2010


Author: mta
Date: 2010-09-06 21:14:24 -0400 (Mon, 06 Sep 2010)
New Revision: 19559
Trac: http://svn.gnucash.org/trac/changeset/19559

Modified:
   gnucash/trunk/src/backend/xml/io-gncxml-v2.c
Log:
Fix bug 573702.  When reading an old data file that doesn't have a template root
account for scheduled transactions invent one.

Modified: gnucash/trunk/src/backend/xml/io-gncxml-v2.c
===================================================================
--- gnucash/trunk/src/backend/xml/io-gncxml-v2.c	2010-09-06 19:50:50 UTC (rev 19558)
+++ gnucash/trunk/src/backend/xml/io-gncxml-v2.c	2010-09-07 01:14:24 UTC (rev 19559)
@@ -305,8 +305,19 @@
     {
         if ( gnc_account_get_parent( (Account*)n->data ) == NULL )
         {
-            /* replace the gnc_book_init-created root account */
-            gnc_book_set_template_root(book, (Account *)n->data);
+            if ( xaccAccountGetType( (Account*)n->data ) == ACCT_TYPE_ROOT )
+            {
+                /* replace the gnc_book_init-created root account */
+                gnc_book_set_template_root(book, (Account *)n->data);
+            }
+            else 
+            {
+                /* This is an old data file that doesn't have a template root
+                   account and this is a top level account.  Make it a child
+                   of the template root account. */
+                acctRoot = gnc_book_get_template_root(book);
+                gnc_account_append_child( acctRoot, (Account*)n->data );
+            }
         }
 
     }



More information about the gnucash-changes mailing list