From 9eeff5dd7eb5d76a7d619409e6eacff0c9e0402d Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 12 Jun 2021 15:21:50 -0700 Subject: [PATCH] Bug 798204 - Creation of Imbalance Accounts Search recursively when getting account by name. --- libgnucash/engine/Scrub.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libgnucash/engine/Scrub.c b/libgnucash/engine/Scrub.c index d54541114a..78e9652bed 100644 --- a/libgnucash/engine/Scrub.c +++ b/libgnucash/engine/Scrub.c @@ -463,7 +463,7 @@ find_root_currency(void) if (xaccAccountGetType (child) == ACCT_TYPE_INCOME) root_currency = xaccAccountGetCommodity (child); } - g_free (children); + g_list_free (children); } return root_currency; } @@ -1453,6 +1453,19 @@ xaccScrubUtilityGetOrMakeAccount (Account *root, gnc_commodity * currency, g_return_val_if_fail (root, NULL); + /* If we're looking for a name, search the whole hierarchy for the name */ + + if (checkname) + { + if (!accname) + return NULL; + acc = gnc_account_lookup_by_name (root, accname); + return acc ? acc : construct_account (root, currency, accname, + acctype, placeholder); + } + /* Otherwise search just the current level. This is used to build + * a hierarchy directly under the root account for trading accounts. + */ acc_list = gnc_account_lookup_by_type_and_commodity (root, checkname ? accname : NULL,