pan-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Pan-users] Pan bug 712539 and 757672


From: Rhialto
Subject: Re: [Pan-users] Pan bug 712539 and 757672
Date: Thu, 10 Mar 2016 00:00:05 +0100
User-agent: Mutt/1.5.24 (2015-08-30)

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.

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.)

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- The Doctor: No, 'eureka' is Greek for
\X/ rhialto/at/xs4all.nl    -- 'this bath is too hot.'

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]