From 37e232fc1012369e77a195b2e75717b0aee7daf9 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Sat, 3 Mar 2007 16:41:42 +0000 Subject: [PATCH] Find the root based off the current account and not the book. It matters in this situation as the accounts haven't actually been added to the book yet. Fixes #414118. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15677 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/app-utils/gnc-ui-util.c | 10 ++++------ src/app-utils/gnc-ui-util.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/app-utils/gnc-ui-util.c b/src/app-utils/gnc-ui-util.c index 7ac2c10ae0..74f2f4e532 100644 --- a/src/app-utils/gnc-ui-util.c +++ b/src/app-utils/gnc-ui-util.c @@ -567,11 +567,10 @@ equity_base_name (GNCEquityType equity_type) } Account * -gnc_find_or_create_equity_account (QofBook *book, +gnc_find_or_create_equity_account (Account *root, GNCEquityType equity_type, gnc_commodity *currency) { - Account *root; Account *parent; Account *account; gboolean name_exists; @@ -582,11 +581,10 @@ gnc_find_or_create_equity_account (QofBook *book, g_return_val_if_fail (equity_type >= 0, NULL); g_return_val_if_fail (equity_type < NUM_EQUITY_TYPES, NULL); g_return_val_if_fail (currency != NULL, NULL); - g_return_val_if_fail (book != NULL, NULL); + g_return_val_if_fail (root != NULL, NULL); base_name = equity_base_name (equity_type); - root = gnc_book_get_root_account(book); account = gnc_account_lookup_by_name(root, base_name); if (account && xaccAccountGetType (account) != ACCT_TYPE_EQUITY) account = NULL; @@ -638,7 +636,7 @@ gnc_find_or_create_equity_account (QofBook *book, parent = root; g_assert(parent); - account = xaccMallocAccount (book); + account = xaccMallocAccount (gnc_account_get_book(root)); xaccAccountBeginEdit (account); @@ -673,7 +671,7 @@ gnc_account_create_opening_balance (Account *account, g_return_val_if_fail (account != NULL, FALSE); equity_account = - gnc_find_or_create_equity_account (book, + gnc_find_or_create_equity_account (gnc_account_get_root(account), EQUITY_OPENING_BALANCE, xaccAccountGetCommodity (account)); if (!equity_account) diff --git a/src/app-utils/gnc-ui-util.h b/src/app-utils/gnc-ui-util.h index d8bf4bdb3c..d5dfee626b 100644 --- a/src/app-utils/gnc-ui-util.h +++ b/src/app-utils/gnc-ui-util.h @@ -161,7 +161,7 @@ typedef enum NUM_EQUITY_TYPES } GNCEquityType; -Account * gnc_find_or_create_equity_account (QofBook *book, +Account * gnc_find_or_create_equity_account (Account *root, GNCEquityType equity_type, gnc_commodity *currency); gboolean gnc_account_create_opening_balance (Account *account,