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

Re: Chaining of dispose and finalize



Jeff Franks wrote:
Russell Shaw wrote:

Hi,

I made an object (View) derived from GObject.

I overide the parent dispose and finalize pointers:


static void view_class_init(ViewClass *klass) { parent_class=g_type_class_peek_parent(klass); // static

    GObjectClass *gobject_class=G_OBJECT_CLASS(klass);
    ViewClass *view_class=VIEW_CLASS(klass);

    gobject_class->dispose=view_dispose;
    gobject_class->finalize=view_finalize;
...
}


This means the next two functions should call g_object_real_dispose() and g_object_finalize():


static void view_dispose(View *view) { if(view->dispose_has_run) return; view->dispose_has_run=TRUE; }

static void
view_finalize(View *view)
{
}


But how do i do that when g_object_real_dispose() and g_object_finalize() are both declared static in gobject.c ?


With lines like these to call the parent (i.e. GObject) functions in view_dispose():

G_OBJECT_CLASS (parent_class)->dispose (view);

But in view_class_init() above, i did: gobject_class->dispose=view_dispose, so G_OBJECT_CLASS(parent_class)->dispose(view) will recursively call itself forever.

and in view_finalize():

G_OBJECT_CLASS (parent_class)->finialize (view);

So will this.


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