Re: GObject finalizers



Hi,

Cedric Marcone <marcone mdeo fr> writes:

> sorry if it's a FAQ but, searching the archives, I couldn't find any
> helpful pointers.
> 
> When calling g_object_unref(), refcount is decremented. If it reaches 0,
> GObjectClass->finalize(Gobject *) is called. And that's a damn good
> thing ;)
> 
> If I subclass GObject with a class containg dynamically allocated
> instance vars, I will need to provide my own finalize() to get rid of
> them, and chain the call to "GObjectClass->finalize()".
> 
> The question is how to provide my own instance finalizer and register
> it...

Register a class initializer and install the instance finalizer there.
Have a look at some example code, almost every GObject does it that
way.


Sven




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