Skip to content

Commit

Permalink
Bug 799347 - Edit account to make it sub account under other account
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jralls committed Jul 2, 2024
1 parent 705a362 commit 60ccca0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libgnucash/engine/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 60ccca0

Please sign in to comment.