Re: whats the difference between dispose and finalizie?
- From: Havoc Pennington <hp redhat com>
- To: rob <mailingLists pangolin org uk>
- Cc: gtk list <gtk-app-devel-list gnome org>
- Subject: Re: whats the difference between dispose and finalizie?
- Date: 27 Apr 2002 11:21:00 -0400
rob <mailingLists pangolin org uk> writes:
I'm trying to port may app to gnome2 but am stuck on how to destroy the
objects.
Firstly it seems that
objectClass->destroy = myDestroyFunc
should change to
objectClass->finalize = myDestroyFunc
but then there is an objectClass->dispose so perhaps destroy has just
changed name? Or dose the dispose function serve some other purpose?
IIRC dispose is like destroy, except that dispose is not a signal.
There may be other small differences. The dispose method for GtkObject
emits the destroy signal, and gtk_object_destroy() runs the dispose
method.
The destroy vs. finalize thing existed in 1.2 as well.
And secondly if my object is also a widget in stead of which ever of the
above is correct I have to go back to the old way of doing things and
overload GtkObject->destory and do all my destroying in there !?
The split between destroy and finalize is the same as for 1.2: destroy
should break references between the object and other objects, or
perhaps better phrased, destroy should return an object to its "new"
state as if the object were just created, where it isn't holding
references to other things. The purpose of destroy is to break
reference count cycles.
While finalize should actually free memory.
<quote>
Also, ::destroy implementations have to release object references that
the object holds. Code in finalize() implementations such as:
if (object->adjustment) {
gtk_object_unref (object->adjustment);
object->adjustment = NULL;
}
have to be moved into the ::destroy implementations.
</quote>
It's confusing that this is in the porting guide, since this was also
true in 1.2 (this code should have been in destroy for 1.2 as well).
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]