[Gnucash-changes] r13599 - gnucash/trunk - The account tree model event handler needs to be more robust in the

David Hampton hampton at cvs.gnucash.org
Sat Mar 11 12:30:55 EST 2006


Author: hampton
Date: 2006-03-11 12:30:54 -0500 (Sat, 11 Mar 2006)
New Revision: 13599
Trac: http://svn.gnucash.org/trac/changeset/13599

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/engine/Group.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
Log:
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.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-03-11 16:02:45 UTC (rev 13598)
+++ gnucash/trunk/ChangeLog	2006-03-11 17:30:54 UTC (rev 13599)
@@ -1,3 +1,12 @@
+2006-03-11  David Hampton  <hampton at 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 at gmx.net>
 
 	* src/gnome-utils/window-main-summarybar.c: Unref the summary bar

Modified: gnucash/trunk/src/engine/Group.c
===================================================================
--- gnucash/trunk/src/engine/Group.c	2006-03-11 16:02:45 UTC (rev 13598)
+++ gnucash/trunk/src/engine/Group.c	2006-03-11 17:30:54 UTC (rev 13599)
@@ -644,7 +644,7 @@
   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 @@
         /* 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;

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c	2006-03-11 16:02:45 UTC (rev 13598)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c	2006-03-11 17:30:54 UTC (rev 13599)
@@ -1443,6 +1443,7 @@
   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 @@
       /* 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 @@
     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 @@
     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");



More information about the gnucash-changes mailing list