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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Chris Shoemaker
> @@ -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
_______________________________________________
gnucash-devel mailing list
[hidden email]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel