From f4d7272312d34d1a00ea274748ef12a74bb8bd24 Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Sat, 15 Aug 2009 21:08:39 +0000 Subject: [PATCH] Ensure template root account is stored even if no scheduled transactions. Otherwise, when it comes time to store the template account before the root, the account has a dangling parent guid. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18251 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/backend/sql/gnc-backend-sql.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/backend/sql/gnc-backend-sql.c b/src/backend/sql/gnc-backend-sql.c index 20fa7722bf..bd5458a663 100644 --- a/src/backend/sql/gnc-backend-sql.c +++ b/src/backend/sql/gnc-backend-sql.c @@ -284,9 +284,16 @@ write_account_tree( GncSqlBackend* be, Account* root ) static gboolean write_accounts( GncSqlBackend* be ) { + gboolean is_ok; + g_return_val_if_fail( be != NULL, FALSE ); - return write_account_tree( be, gnc_book_get_root_account( be->primary_book ) ); + is_ok = write_account_tree( be, gnc_book_get_root_account( be->primary_book ) ); + if( is_ok ) { + is_ok = write_account_tree( be, gnc_book_get_template_root( be->primary_book ) ); + } + + return is_ok; } static int @@ -334,10 +341,7 @@ write_template_transactions( GncSqlBackend* be ) data.be = be; ra = gnc_book_get_template_root( be->primary_book ); if( gnc_account_n_descendants( ra ) > 0 ) { - data.is_ok = write_account_tree( be, ra ); - if( data.is_ok ) { - (void)xaccAccountTreeForEachTransaction( ra, write_tx, &data ); - } + (void)xaccAccountTreeForEachTransaction( ra, write_tx, &data ); } return data.is_ok;