On Thu, 10 Mar 2016 00:00:05 +0100 Rhialto <rhialto-vhf8exz4...@public.gmane.org> wrote:
> On Wed 09 Mar 2016 at 22:42:26 +0100, Petr Kovar wrote: > > Thanks for all the info, Olaf! So this patch will do? > > > > --- /tmp/ezzIwP_body-pane.cc > > +++ /tmp/pan2/pan/gui/body-pane.cc > > @@ -1637,7 +1637,6 @@ > > > > { > > gtk_container_remove (GTK_CONTAINER (_att_frame), _att_toolbar); > > - if (G_IS_OBJECT(_att_toolbar)) g_object_unref(_att_toolbar); > > (void)create_attachments_toolbar(_att_frame); > > } > > > > Yes, that should do it. Or even better would be > > - if (G_IS_OBJECT(_att_toolbar)) g_object_unref(_att_toolbar); > + _att_toolbar = NULL; > > that would make it clearer if _att_toolbar is accidentally used later > on. Cool, I've just pushed the patch to master. Thanks again! > I have double-checked it, and I am basing my reasoning on this documentation: > https://developer.gnome.org/gtk2/stable/GtkContainer.html > The description for gtk_container_remove() mentions refcounts, but > gtk_container_add() doesn't. gtk_table_new() > doesn't mention refcounts either; I would have liked some reference to > https://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#floating-ref > or > https://developer.gnome.org/gobject/unstable/gobject-memory.html#gobject-destruction-table > (which took some clicking around to find). > It seems that the general pattern is that gtk_table_new() would create a > "floating reference" and gtk_container_add() would turn that into a > normal reference. gtk_container_remove() would finally remove it, and > because it is now zero the object gets deleted. > > (An alternative approach could be to add a refcount to _att_toolbar > just after creating it, but I don't see any particular advantage to that > at the moment.) > > Shall I look at some more of these, later on? (After the currently > pending changes; I don't want to mix too many things at the same time.) That'd be great, really. Anything that improves the Pan code base is much needed at this point. :) pk _______________________________________________ Pan-users mailing list Pan-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/pan-users