[Gnucash-changes] r14283 - gnucash/trunk - Replace
gnc_tree_model_account_path_changed with manual checks whether
Chris Shoemaker
c.shoemaker at cox.net
Wed May 31 20:47:53 EDT 2006
On Wed, May 31, 2006 at 08:01:02PM -0400, Chris Shoemaker wrote:
> On Wed, May 31, 2006 at 03:30:51PM -0400, Andreas Köhler wrote:
> > Author: andi5
> > Date: 2006-05-31 15:30:49 -0400 (Wed, 31 May 2006)
> > New Revision: 14283
> > Trac: http://svn.gnucash.org/trac/changeset/14283
> >
> > Modified:
> > gnucash/trunk/ChangeLog
> > gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
> > Log:
> > Replace gnc_tree_model_account_path_changed with manual checks whether
> > the inserted (resp. deleted) account is the first (resp. last) account
> > in its level and call gtm_row_has_child_toggled only in these cases.
> > Might fix #343405, as GtkTreeModelFilter seems to make (false)
> > assumptions when being woken up too often.
> >
>
> I think there are some problems with this...
>
> 1) That stamp increment might not have been exactly correct, but I
> think it's technically required. You've removed it entirely. This
> model does not advertise persistent iters, and every insert or remove
> event will invalidate the iters for the paths after the "event-path"
> at the same depth.
>
> 2) The old code would emit row_changed on all the ancestors of the
> inserted or deleted account. I think that was correct behavior, since
> the inserted or deleted row may change the totals for the ancestor
> rows.
BTW, I think the need for this behavior can be demonstrated by hiding
out zero total accounts and then reparenting an account from a parent
with one child to an account that _was_ zero balance. Since no
row_changed is emitted for the old parent, the filter model doesn't
know that it should filter out that row. The sort model then gets
confused. I get a (gnucash:22792): Gtk-CRITICAL **:
gtk_tree_model_sort_row_inserted: assertion `elt != NULL' failed. And
then the treeview behaves strangely.
-chris
>
> But, if being more strict about has_child_toggled fixes the crash, we
> should obviously do that.
>
> I'll work on restoring those two behaviors while keeping the new.
> Hopefully, that will still not crash...
>
> -chris
>
> >
> > Modified: gnucash/trunk/ChangeLog
> > ===================================================================
> > --- gnucash/trunk/ChangeLog 2006-05-31 05:15:28 UTC (rev 14282)
> > +++ gnucash/trunk/ChangeLog 2006-05-31 19:30:49 UTC (rev 14283)
> > @@ -1,3 +1,12 @@
> > +2006-05-31 Andreas Köhler <andi5.py at gmx.net>
> > +
> > + * src/gnome-utils/gnc-tree-model-account.c: Replace
> > + gnc_tree_model_account_path_changed with manual checks whether
> > + the inserted (resp. deleted) account is the first (resp. last)
> > + account in its level and call gtm_row_has_child_toggled only in
> > + these cases. Might fix #343405, as GtkTreeModelFilter seems to
> > + make (false) assumptions when being woken up too often.
> > +
> > 2006-05-31 Derek Atkins <derek at ihtfp.com>
> >
> > * po/es.po: Updated Spanish Translation from Eneko Lacunza
> >
> > Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
> > ===================================================================
> > --- gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c 2006-05-31 05:15:28 UTC (rev 14282)
> > +++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c 2006-05-31 19:30:49 UTC (rev 14283)
> > @@ -1426,41 +1426,6 @@
> > /* Account Tree Model - Engine Event Handling Functions */
> > /************************************************************/
> >
> > -/** This function performs common updating to the model after an
> > - * account has been added or removed. The parent entry needs to be
> > - * tapped on the shoulder so that it can correctly update the
> > - * disclosure triangle (first added child/last removed child) or
> > - * possibly rebuild its child list of that level of accounts is
> > - * visible.
> > - *
> > - * @internal
> > - *
> > - * @param model The account tree model containing the account that
> > - * has been added or deleted.
> > - *
> > - * @param path The path to the newly added item, or the just removed
> > - * item.
> > - */
> > -static void
> > -gnc_tree_model_account_path_changed (GncTreeModelAccount *model,
> > - GtkTreePath *path)
> > -{
> > - GtkTreeIter iter;
> > -
> > - while (gtk_tree_path_get_depth(path) > 0) {
> > - if (!gtk_tree_model_get_iter (GTK_TREE_MODEL(model), &iter, path))
> > - break;
> > - gtk_tree_model_row_changed (GTK_TREE_MODEL(model), path, &iter);
> > - gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL(model), path, &iter);
> > - gtk_tree_path_up(path);
> > - }
> > -
> > - do {
> > - model->stamp++;
> > - } while (model->stamp == 0);
> > -}
> > -
> > -
> > /** This function is the handler for all event messages from the
> > * engine. Its purpose is to update the account tree model any time
> > * an account is added to the engine or deleted from the engine.
> > @@ -1533,8 +1498,10 @@
> > break;
> > }
> > gtk_tree_model_row_inserted (GTK_TREE_MODEL(model), path, &iter);
> > - if (gtk_tree_path_up (path))
> > - gnc_tree_model_account_path_changed(model, path);
> > + if (gtk_tree_path_up (path) &&
> > + gtk_tree_model_get_iter (GTK_TREE_MODEL(model), &iter, path) &&
> > + gtk_tree_model_iter_n_children (GTK_TREE_MODEL(model), &iter) == 1)
> > + gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL(model), path, &iter);
> > break;
> >
> > case QOF_EVENT_REMOVE:
> > @@ -1550,7 +1517,10 @@
> > }
> > gtk_tree_path_append_index (path, ed->idx);
> > gtk_tree_model_row_deleted (GTK_TREE_MODEL(model), path);
> > - gnc_tree_model_account_path_changed(model, path);
> > + if (gtk_tree_path_up (path) &&
> > + gtk_tree_model_get_iter (GTK_TREE_MODEL(model), &iter, path) &&
> > + gtk_tree_model_iter_n_children (GTK_TREE_MODEL(model), &iter) == 0)
> > + gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL(model), path, &iter);
> > break;
> >
> > case QOF_EVENT_MODIFY:
> >
> > _______________________________________________
> > gnucash-changes mailing list
> > gnucash-changes at gnucash.org
> > https://lists.gnucash.org/mailman/listinfo/gnucash-changes
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
More information about the gnucash-devel
mailing list