gnucash stable: Bug 799347 - Edit account to make it sub account under other account
John Ralls
jralls at code.gnucash.org
Tue Jul 2 00:34:11 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/60ccca01 (commit)
from https://github.com/Gnucash/gnucash/commit/705a362e (commit)
commit 60ccca017f1be3af2caebb8a9d0c82a197f1da4f
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Jul 1 21:28:43 2024 -0700
Bug 799347 - Edit account to make it sub account under other account
Send QOF_EVENT_REMOVE on the child before actually removing it from
the children vector so that the stored indexes are valid long enough
to clear them.
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index 3289680eda..f125692816 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -2859,11 +2859,13 @@ gnc_account_remove_child (Account *parent, Account *child)
ed.node = parent;
ed.idx = gnc_account_child_index (parent, child);
+ // First send the event before we invalidate everything in children.
+ qof_event_gen(&child->inst, QOF_EVENT_REMOVE, &ed);
+
+ // Then remove the child and release its memory.
ppriv->children.erase (std::remove (ppriv->children.begin(), ppriv->children.end(), child),
ppriv->children.end());
- /* Now send the event. */
- qof_event_gen(&child->inst, QOF_EVENT_REMOVE, &ed);
/* clear the account's parent pointer after REMOVE event generation. */
cpriv->parent = nullptr;
Summary of changes:
libgnucash/engine/Account.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
More information about the gnucash-changes
mailing list