> It is used since we store pointers to all widgets in the datalist of the
> toplevel widget, by calling gtk_object_set_data_full(). These pointers
> are used for the lookup_widget() utility function Glade provides.

That sounds a bit like treating gtk+ objects like bonobo objects.  Whenever
a pointer to the object is kept, ref the pointer.  When removed, unref it.
Considering that I would like to add an option to create bonobo objects from
glade top-level widgets, I might be better off keeping the ref/unref
mechanism.  I was reading Havoc's book over the weekend, and he gives a
decent description of the three-phase destruction of a gtk+ object.  Seems
like a little-used practice based on the code examples in the book, but I
see no harm in using it.

> If we didn't use the ref/unref, and a widget in the interface was
> removed, then using lookup_widget() would return an invalid memory
> address and the app would probably crash.
>
> Though to be honest I'm not sure it is that useful. People rarely
> remove widgets, and if they do they should know not to call
lookup_widget()
> for it.

I suppose if someone did write an app that dynamically creates/removes
widgets, using glade without ref/unref code would be prohibitive.

How about if I put the ref/unref code in the constructor/destructor for each
top-level widget.

typedef struct tag_Whatever
{
    GtkWidget *thing1;
    GtkWidget *thing2;
} Whatever;

Whatever *whatever_create( ) {
    // ref thing1 and thing2
}

void whatever_destroy( Whatever *whatever ) {
    // unref thing1 and thing2
}

Sound good?

John


_______________________________________________
Glade-devel maillist  -  [EMAIL PROTECTED]
http://lists.helixcode.com/mailman/listinfo/glade-devel

Reply via email to