From c3eaff9bb2c704a3367fe5eb4f790e6c9925b222 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 9 Dec 2021 12:57:45 +0800 Subject: [PATCH] [account.cpp] gnc_account_and_descendants_empty: don't copy children --- libgnucash/engine/Account.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index ee375d3046..e1e8e0f3d7 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -4011,15 +4011,14 @@ as well, use gnc_account_and_descendants_empty."); gboolean gnc_account_and_descendants_empty (Account *acc) { g_return_val_if_fail (GNC_IS_ACCOUNT (acc), FALSE); - if (xaccAccountGetSplitList (acc)) return FALSE; - auto empty = TRUE; - auto *children = gnc_account_get_children (acc); - for (auto *n = children; n && empty; n = n->next) + auto priv = GET_PRIVATE (acc); + if (priv->splits != nullptr) return FALSE; + for (auto *n = priv->children; n; n = n->next) { - empty = gnc_account_and_descendants_empty ((Account*)n->data); + if (!gnc_account_and_descendants_empty (static_cast(n->data))) + return FALSE; } - g_list_free (children); - return empty; + return TRUE; } LotList *