Re: g_object_ref_sink and GUnowned



On Thu, 2005-12-22 at 17:49 +0100, Tim Janik wrote:

>    GtkObject derives from GUnowned

This breaks the Perl bindings of GTK+.

Our GTK+ bindings register GtkObject with our GLib bindings at start up.
This involves associating it with the namespace Gtk2::Object and it
usually also means setting up inheritance so that Gtk2::Object is a
Glib::Object.  For that, the GLib bindings look at the parent of the
type and, if it is known to the bindings, put the associated namespace
into Perl's inheritance mechanism.

GInitiallyUnowned is not known to our GLib bindings, though, which
results in Gtk2::Object having no ancestor.  That in turn means that
things like windows, containers, etc. are no Glib::Object -- they don't
have access to, say, the signal and property API anymore.  This breaks
every non-trivial Gtk2-Perl program.  Even if we added support for
GInitiallyUnowned now, older versions of our bindings would still break
if the underlying GLib is updated without also updating the bindings.

Now, you could argue that our bindings should really walk up the whole
ancestry until something known is reached instead of just looking at the
direct parent.  And I would probably agree; this has caused us problems
in a different context as well.  However, the current approach works
with all combinations of GLib 2.[02468] and GTK+ 2.[02468].  The only
thing it assumes is that the object hierarchy doesn't suddenly contain
unknown types, which is, I think, a sensible assumption.

For reference, the code that implements the described approach is in
gperl_register_object:

http://cvs.sourceforge.net/viewcvs.py/gtk2-perl/gtk2-perl-xs/Glib/GObject.xs?rev=1.53&view=markup

The GTK+ bindings use

  gperl_register_object (GTK_TYPE_OBJECT, "Gtk2::Object")

to register the type.

-- 
Bye,
-Torsten




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