From 6aa35ea7fb9e9facba6d0dd6525ffaa7f65e78ad Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sat, 12 Jun 2021 16:42:10 -0700 Subject: [PATCH] Better fix for bug 798204, doesn't break trading account selection. --- libgnucash/engine/Account.cpp | 12 ++++++++++++ libgnucash/engine/Scrub.c | 13 ------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index 5cea5e022e..154ff19361 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -3145,6 +3145,18 @@ gnc_account_lookup_by_type_and_commodity (Account* root, retval = g_list_prepend(retval, account); } } + + if (!retval) // Recurse through the children + for (auto node = rpriv->children; node; node = node->next) + { + auto account{static_cast(node->data)}; + auto result = gnc_account_lookup_by_type_and_commodity(account, + name, + acctype, + commodity); + if (result) + retval = g_list_concat(result, retval); + } return retval; } diff --git a/libgnucash/engine/Scrub.c b/libgnucash/engine/Scrub.c index 78e9652bed..88965cefb0 100644 --- a/libgnucash/engine/Scrub.c +++ b/libgnucash/engine/Scrub.c @@ -1453,19 +1453,6 @@ 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,