GObject destruction
- From: Jacob Kroon <jacob kroon gmail com>
- To: gtk-list gnome org
- Subject: GObject destruction
- Date: Sun, 12 Feb 2006 16:44:49 +0100
Hi,
I've read the GObject tutorial, and I'm trying to understand how to
implement the dispose/finalize
functionality. They way I see it, the you need to override dispose in
GObjectClass, and that this
method should g_object_unref() any objects which the instance uses, and
that finalize() should release
any allocated memory etc. Dispose might be called more than once, so one
needs to guard against
multiple invocations using some sort of flag. My question is, will every
class I create always need to have a
DISPOSED attribute (for instance a flag, or an int) in order to
implement this correctly ? (Unless of course
the instance doesn't refererence any other instances, in which case I
don't need to implements dispose()).
Maybe theres a way to implement it using a "destroy" signal, which each
subclass connects a callback to,
and does its cleanup's in, and have only the parent class guard against
multiple invocations. The parent class
would then implement dispose, have a flag guarding against multiple
invocation, and do signal_emit("destroy")
in dispose(). Could this work ?
I've tried looking at Gtk+ code to see how GtkObject/GtkWidget's handle
it, buts it's over my head.
I apologize in advance if I'm not giving enough information concerning
my problem.
//Jacob
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]