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.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/remove-group@14715 57a11ea4-9604-0410-9ed3-97b8803252fd
archive
David Hampton 20 years ago committed by John Ralls
parent 9ee43458cd
commit 97e65c9d74

@ -94,6 +94,11 @@
2006-08-20 David Hampton <hampton@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.

@ -190,12 +190,6 @@ add_account_local(sixtp_gdv2 *data, Account *act)
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 @@ qof_session_load_from_xml_file_v2_full(
gnc_account_foreach_descendant(root,
(AccountCb) xaccAccountCommitEdit,
NULL);
xaccAccountCommitEdit (root);
/* start logging again */
xaccLogEnable ();

@ -180,9 +180,14 @@ Account *
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

Loading…
Cancel
Save