Re: GType/GObject questions



Havoc Pennington <hp redhat com> writes:

> I believe this is the same as GtkObject and I explain it in my book,
> but I don't remember the answer. I'm pretty sure that
> http://developer.gnome.org/doc/GGAD/ in the GtkObject chapter tells
> you what base init does.
> 
> I do remember that base init is almost never useful.

The canonical example of base_init is for the arg_set and arg_get
functions in GtkObject

arg_get() is unusual in that when you call gtk_object_get(), it
doesn't just call arg_get() for the class itself; instead it
calls arg_get for the class, and if that fails, calls arg_get()
for the parent class and so forth.

So, when deriving, if the pointer to the parent class's arg_get()
function was copied in when initializing the derived class structure
as normal, then you would get incorrect operation since the parent
classes arg_get() function would be called twice.

the base_init function for GtkObject is used to set the arg_get pointer
in the class structure to NULL and to avoid the problem.

(Not a very clear explanation, I'm afraid - you'd be best off going
to look in GGAD probably.)

Regards,
                                        Owen




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