r18240 - gnucash/trunk/src/backend/sql - Save and restore root account to SQL dbs
Phil Longstaff
plongstaff at code.gnucash.org
Sun Aug 9 13:26:16 EDT 2009
Author: plongstaff
Date: 2009-08-09 13:26:16 -0400 (Sun, 09 Aug 2009)
New Revision: 18240
Trac: http://svn.gnucash.org/trac/changeset/18240
Modified:
gnucash/trunk/src/backend/sql/gnc-account-sql.c
gnucash/trunk/src/backend/sql/gnc-backend-sql.c
Log:
Save and restore root account to SQL dbs
Modified: gnucash/trunk/src/backend/sql/gnc-account-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-account-sql.c 2009-08-08 16:19:57 UTC (rev 18239)
+++ gnucash/trunk/src/backend/sql/gnc-account-sql.c 2009-08-09 17:26:16 UTC (rev 18240)
@@ -167,9 +167,10 @@
gnc_sql_load_object( be, row, GNC_ID_ACCOUNT, pAccount, col_table );
xaccAccountCommitEdit( pAccount );
- /* If we don't have a parent, it might be because the parent account hasn't
- been loaded yet. Remember the account and its parent guid for later. */
- if( gnc_account_get_parent( pAccount ) == NULL ) {
+ /* If we don't have a parent and this isn't the root account, it might be because the parent
+ account hasn't been loaded yet. Remember the account and its parent guid for later. */
+ if( gnc_account_get_parent( pAccount ) == NULL
+ && pAccount != gnc_book_get_root_account( be->primary_book ) ) {
account_parent_guid_struct* s = g_malloc( (gsize)sizeof(account_parent_guid_struct) );
g_assert( s != NULL );
Modified: gnucash/trunk/src/backend/sql/gnc-backend-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-backend-sql.c 2009-08-08 16:19:57 UTC (rev 18239)
+++ gnucash/trunk/src/backend/sql/gnc-backend-sql.c 2009-08-09 17:26:16 UTC (rev 18240)
@@ -267,12 +267,16 @@
g_return_val_if_fail( be != NULL, FALSE );
g_return_val_if_fail( root != NULL, FALSE );
- descendants = gnc_account_get_descendants( root );
- for( node = descendants; node != NULL && is_ok; node = g_list_next(node) ) {
- is_ok = gnc_sql_save_account( be, QOF_INSTANCE(GNC_ACCOUNT(node->data)) );
- update_save_progress( be );
- }
- g_list_free( descendants );
+ is_ok = gnc_sql_save_account( be, QOF_INSTANCE(root) );
+ if( is_ok ) {
+ descendants = gnc_account_get_descendants( root );
+ for( node = descendants; node != NULL && is_ok; node = g_list_next(node) ) {
+ is_ok = gnc_sql_save_account( be, QOF_INSTANCE(GNC_ACCOUNT(node->data)) );
+ if( !is_ok ) break;
+ update_save_progress( be );
+ }
+ g_list_free( descendants );
+ }
return is_ok;
}
More information about the gnucash-changes
mailing list