Re: GtkWindow destroy problem



On 6 Sep 2001, Havoc Pennington wrote:

>
> Tim Janik <timj gtk org> writes:
> > 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);
> > the object will be correctly destroyed but never had someone resetting its
> > floating flag (e.g. for a widget that means it got never added to a container).
>
> Basically I don't think that code should be valid, because it involves
> removing a reference you don't own and relying on implicit knowledge
> that no one else will do so.
>
> The actual code people write will always be more complicated and the
> unref() after doing anything more complicated (for example, invoking a
> function on the object) is definitely wrong, because it is legitimate
> for anyone to sink an object, and you don't know if they have.
>
> Plus allowing this code does not add any useful feature; because you
> could always write gtk_object_sink() instead of the unref().

Just for reference, pygtk does a ref+sink in the constructor for GtkObject
derived GObjects.  It will probably be necessary for martin to do
something similar in his guile binding.

James.





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