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.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13599 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2006-03-11 17:30:54 +00:00
parent 2a3b4aa51f
commit 4d2d52413a
3 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,12 @@
2006-03-11 David Hampton <hampton@employees.org>
* 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 <andi5.py@gmx.net>
* src/gnome-utils/window-main-summarybar.c: Unref the summary bar

View File

@ -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;

View File

@ -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");