r14715 - gnucash/branches/remove-group - Make sure the root account exists when the code asks for it. This

David Hampton hampton at cvs.gnucash.org
Tue Aug 22 23:17:32 EDT 2006


Author: hampton
Date: 2006-08-22 23:17:29 -0400 (Tue, 22 Aug 2006)
New Revision: 14715
Trac: http://svn.gnucash.org/trac/changeset/14715

Modified:
   gnucash/branches/remove-group/ChangeLog
   gnucash/branches/remove-group/src/backend/file/io-gncxml-v2.c
   gnucash/branches/remove-group/src/engine/Account.c
Log:
Make sure the root account exists when the code asks for it.  This
works both for reading a new file and a user performing
File->New->New File.


Modified: gnucash/branches/remove-group/ChangeLog
===================================================================
--- gnucash/branches/remove-group/ChangeLog	2006-08-23 03:09:40 UTC (rev 14714)
+++ gnucash/branches/remove-group/ChangeLog	2006-08-23 03:17:29 UTC (rev 14715)
@@ -1,5 +1,10 @@
 2006-08-22  David Hampton  <hampton at employees.org>
 
+	* src/backend/file/io-gncxml-v2.c:
+	* src/engine/Account.c: Make sure the root account exists when the
+	code asks for it.  This works both for reading a new file and a
+	user performing File->New->New File.
+
 	* src/gnome-utils/gnc-tree-model-account.c: Fix a mistake in the
 	updated tree model.
 

Modified: gnucash/branches/remove-group/src/backend/file/io-gncxml-v2.c
===================================================================
--- gnucash/branches/remove-group/src/backend/file/io-gncxml-v2.c	2006-08-23 03:09:40 UTC (rev 14714)
+++ gnucash/branches/remove-group/src/backend/file/io-gncxml-v2.c	2006-08-23 03:17:29 UTC (rev 14715)
@@ -190,12 +190,6 @@
       parent = gnc_account_get_parent(act);
       if (parent == NULL) {
 	root = gnc_book_get_root_account(data->book);
-	if (root == NULL) {
-	  root = gnc_account_create_root(data->book);
-	  /* Leave the account in the edit state. It will be committed
-	   * at the end of reading all the transactions. */
-	  xaccAccountBeginEdit(root);
-	}
 	gnc_account_append_child(root, act);
       }
     }
@@ -776,7 +770,6 @@
     gnc_account_foreach_descendant(root,
 				   (AccountCb) xaccAccountCommitEdit,
 				   NULL);
-    xaccAccountCommitEdit (root);
 
     /* start logging again */
     xaccLogEnable ();

Modified: gnucash/branches/remove-group/src/engine/Account.c
===================================================================
--- gnucash/branches/remove-group/src/engine/Account.c	2006-08-23 03:09:40 UTC (rev 14714)
+++ gnucash/branches/remove-group/src/engine/Account.c	2006-08-23 03:17:29 UTC (rev 14715)
@@ -180,9 +180,14 @@
 gnc_book_get_root_account (QofBook *book)
 {
   QofCollection *col;
+  Account *root;
+
   if (!book) return NULL;
   col = qof_book_get_collection (book, GNC_ID_ROOT_ACCOUNT);
-  return gnc_coll_get_root_account (col);
+  root = gnc_coll_get_root_account (col);
+  if (root == NULL)
+    root = gnc_account_create_root(book);
+  return root;
 }
 
 void



More information about the gnucash-changes mailing list