diff --git a/ChangeLog b/ChangeLog index 991887dfd5..8e7e25cb41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-03-11 David Hampton + + * src/gnome-utils/gnc-tree-model-account.c: + * src/engine/Group.c: The account tree model event handler needs + to be more robust in the case of multiple account sets existing at + the same time. Pass the account group instead of the parent + account so that its possible to determine which model a "top + level" account belongs to. Fixes 333866. + 2006-03-11 Andreas Köhler * src/gnome-utils/window-main-summarybar.c: Unref the summary bar diff --git a/src/engine/Group.c b/src/engine/Group.c index 406ab2c266..f1cadfe7b1 100644 --- a/src/engine/Group.c +++ b/src/engine/Group.c @@ -644,7 +644,7 @@ xaccGroupRemoveAccount (AccountGroup *grp, Account *acc) acc->parent = NULL; /* Gather event data */ - ed.node = grp->parent; /* The parent account */ + ed.node = grp; ed.idx = g_list_index(grp->accounts, acc); grp->accounts = g_list_remove (grp->accounts, acc); @@ -926,10 +926,8 @@ xaccGroupMergeAccounts (AccountGroup *grp) /* move back one before removal */ node_b = node_b->prev; - /* remove from list -- node_a is ok, it's before node_b */ - qof_event_gen (&acc_b->inst.entity, QOF_EVENT_REMOVE, NULL); - grp->accounts = g_list_remove (grp->accounts, acc_b); - + /* The destroy function will remove from list -- node_a is ok, + * it's before node_b */ xaccAccountBeginEdit (acc_b); xaccAccountDestroy (acc_b); break; diff --git a/src/gnome-utils/gnc-tree-model-account.c b/src/gnome-utils/gnc-tree-model-account.c index 29f8ae6153..6df6aceb7b 100644 --- a/src/gnome-utils/gnc-tree-model-account.c +++ b/src/gnome-utils/gnc-tree-model-account.c @@ -1443,6 +1443,7 @@ gnc_tree_model_account_event_handler (QofEntity *entity, GtkTreePath *path = NULL; GtkTreeIter iter; Account *account, *parent; + AccountGroup *group; g_return_if_fail(model); /* Required */ if (!GNC_IS_ACCOUNT(entity)) @@ -1458,6 +1459,10 @@ gnc_tree_model_account_event_handler (QofEntity *entity, /* Tell the filters/views where the new account was added. */ account = GNC_ACCOUNT(entity); DEBUG("add account %p (%s)", account, xaccAccountGetName(account)); + if (xaccAccountGetRoot(account) != priv->root) { + LEAVE("not in this model"); + return; + } path = gnc_tree_model_account_get_path_from_account(model, account); if (!path) { DEBUG("can't generate path"); @@ -1475,8 +1480,15 @@ gnc_tree_model_account_event_handler (QofEntity *entity, case QOF_EVENT_REMOVE: if (!ed) /* Required for a remove. */ break; - parent = ed->node ? GNC_ACCOUNT(ed->node) : priv->toplevel; - parent_name = ed->node ? xaccAccountGetName(parent) : "Root"; + group = ed->node; + if (xaccGroupGetRoot(group) != priv->root) { + LEAVE("not in this model"); + return; + } + parent = xaccGroupGetParentAccount(ed->node); + if (!parent) + parent = priv->toplevel;; + parent_name = parent ? xaccAccountGetName(parent) : "Root"; DEBUG("remove child %d of account %p (%s)", ed->idx, parent, parent_name); path = gnc_tree_model_account_get_path_from_account(model, parent); if (!path) { @@ -1491,6 +1503,10 @@ gnc_tree_model_account_event_handler (QofEntity *entity, case QOF_EVENT_MODIFY: account = GNC_ACCOUNT(entity); DEBUG("modify account %p (%s)", account, xaccAccountGetName(account)); + if (xaccAccountGetRoot(account) != priv->root) { + LEAVE("not in this model"); + return; + } path = gnc_tree_model_account_get_path_from_account(model, account); if (!path) { DEBUG("can't generate path");