Re: Can I use gtk_widget_unref() to releasetthe object created by gtk_invisible_new()?
- From: Markku Vire <markku vire iki fi>
- To: Brian Lu <Brian Lu Sun COM>
- Cc: gtk-devel-list gnome org
- Subject: Re: Can I use gtk_widget_unref() to releasetthe object created by gtk_invisible_new()?
- Date: Thu, 10 Jan 2008 23:35:54 +0200
The caller doesn't own the returned reference in case of any gtk_*_new
functions, but the results are floating references (they are removed
once somebody calls gtk_object_sink). This is different from normal
GObjects. So, unreffing the returned value causes practically a double
gtk_widget_destroy in turn runs dispose, ie. asks widget to drop
references to other widgets. Dropping external references usually causes
somebody else to drop the last reference to your widget, so it
efectively gets destroyed. In case of toplevels some global window list
is holding the reference.
Calling gtk_widget_destroy without taking ownership a a widget is
usually a bug that causes a memory leak, but this is not the case here,
since we are talking about a toplevel.
On Wed, 2008-01-09 at 17:39 +0800, Brian Lu wrote:
> Hi, experts,
> I found following codes will crash in gnome 2.21 environment:
> GtkWidget *foo = gtk_invisible_new();
> But it works well if gtk_widget_unref() is replaced with
> Does that mean that we can't use gtk_widget_unref() on such object and
> we can only
> use gtk_widget_destroy() to release it?
> gtk-devel-list mailing list
> gtk-devel-list gnome org
] [Thread Prev