Re: Chaining of dispose and finalize



John Cupitt wrote:
On Sat, 04 Sep 2004 00:39:27 +1000, Russell Shaw <rjshaw netspace net au> wrote:

I understand that, and is what i do. What i mean is that most
objects do in class_init something like:

  gobject_class->dispose=myobject_dispose;

But this makes the original dispose code in gobject
inaccessible. Same for gobject_class->dispose=myobject_finalize.


That assignment isn't overwriting gobject's dispose, it's setting the
gobject dispose for this class. If you have a class called myclass
derived from gobject, then that class has two ->dispose() function
pointers: the standard gobject one, and the one you set. That's
because every time you make a class, you get a fresh copy of every
class above this one in the inheritance hierarchy.

I didn't realize copies of classes were stored in the g_type system.

I found that "The Glib Object system v0.9.0" has the information
in it:

  http://le-hacker.org/papers/gobject/ch05.html#howto-gobject-chainup

I had read only V0.8.0.

Classes and class instances don't behave the same. When you make a
class instance, you are building a single big, overlapping struct. You
can override things in your parent classes.

When you derive a new class, you build a lot of structs: one for each
class in the hierarchy. When you chain up at the end of dispose,
you're jumping up one struct in this pile of structs.

I knew that bit;)

(hope I've understood you here, sorry if I've missed the point)




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