[Gnucash-changes] Unref the sort_model so that the entire set of models will be properly

Chris Shoemaker c.shoemaker at cox.net
Thu Jun 9 18:21:41 EDT 2005


> @@ -403,8 +404,9 @@
>  
>    /* Set up the view private sort layer on the common model. */
>    s_model = gtk_tree_model_sort_new_with_model(f_model);
> -  gnc_tree_view_set_model (view, s_model);
>    g_object_unref(G_OBJECT(f_model));
> +  gnc_tree_view_set_model (view, s_model);
> +  g_object_unref(G_OBJECT(s_model));
>  
>    /* Set default visibilities */
>    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);

Good find!  I was looking for this bug a few days ago, but I gave up.  :)

This was causing the filter model's filter function callback to be
called even after the view had been finalized.  grrr....

The key here is realizing that GtkTreeSortModel does not derive from
GtkObject, so it does not have the floating ref that would be sunk
when you add it to some other widget.  It's a gobject, so you own the
first ref upon creation.  The view takes its own ref of the model and
drops it when it finalizes, but if you never drop yours... BAM!

-chris


More information about the gnucash-devel mailing list