Re: How to destroy GtkAdjustments?
- From: Havoc Pennington <hp redhat com>
- To: learfox furry ao net
- Cc: GTK Applocation Development List <gtk-app-devel-list gnome org>
- Subject: Re: How to destroy GtkAdjustments?
- Date: 05 Oct 2000 00:31:56 -0400
learfox furry ao net writes:
When I create a adjustment using gtk_adjustment_new().
How do I destroy it? Do I need to destroy all widgets that referance
it first? Do I use gtk_object_destroy() or gtk_object_unref()?
Any GtkObject works as follows.
On creation (return from whatever_new()), the object has a floating
reference count. No one owns this reference count. However, anyone is
allowed to remove it by calling gtk_object_sink(). gtk_object_sink()
strips the floating reference; if the floating reference was the only
reference the object would be dead.
w = whatever_new ();
gtk_object_sink (GTK_OBJECT (w)); /* w is now dead */
If you want to keep the object around, you should add a reference that
you own, since anyone can remove the floating reference at any
time. So if you intend to keep the object:
w = whatever_new ();
gtk_object_ref (GTK_OBJECT (w));
then later, since you added a reference and thus own a reference,
you must call gtk_object_unref().
But; we're leaving out the point of the floating
reference. Conventionally, any "long term owner" of the object strips
the floating reference after adding its own reference. For example, if
you add a widget to a container, the container will ref/sink the child
widget:
w = whatever_new ();
gtk_container_add (container, w);
here, w no longer has a floating reference, and the container owns one
reference. So when the container is destroyed, w will also be
unref()'d for the last time and go away. So you don't need to do
anything.
When you call set_adjustments() or otherwise pass an adjustment to an
owner, the same thing happens. So you don't need to unref the
adjustment unless you own a reference, and you don't own a reference
unless you called ref().
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]