Re: GtkWindow destroy problem



Martin Baulig <martin home-of-linux org> writes:

> Darin Adler <darin bentspoon com> writes:
> 
> > on 9/5/01 11:42 PM, Tim Janik at timj gtk org wrote:
> > 
> > > not in GtkObject, since this is valid code (apart from GTK_TYPE_OBEJCT
> > > being abstract):
> > > o = g_object_new (GTK_TYPE_OBJECT, NULL);
> > > gtk_object_unref (o);
> > 
> > If anyone other than you tried to tell me this was valid, I would tell him
> > he was wrong.
> > 
> > Havoc has drilled it into my head over the last year that the floating
> > reference cannot be legally removed with unref.
> 
> Ok, so just to make sure I did it right, is the following correct ?
> 
>   o = g_object_new (GTK_TYPE_WINDOW, NULL);
>   gtk_object_ref (o);
>   gtk_object_sink (o);
>   /* ... some time later ... */
>   g_object_unref (o);

Yes it's correct if you don't expect it to free the window. From any
language, a GtkWindow will live until someone explicitely calls its
destroy() method. GtkWindow widgets don't disappear just because the
last reference to them was droppped.

The self ref/sink for GtkWindow occurs inside it's init() method,
you can't intercept it, and it would be broken if you could.

                                        Owen




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