Re: widget with label (reference counts)
- From: Tristan Van Berkom <vantr touchtunes com>
- To: Havoc Pennington <hp redhat com>
- Cc: Fabio Zanetta <znt fabio virgilio it>, "GTK2.0" <gtk-app-devel-list gnome org>
- Subject: Re: widget with label (reference counts)
- Date: Tue, 12 Nov 2002 16:29:18 -0500
Thanks for the clarification;
do _all_ newly created GtkObjects start
with a floating reference and a reference count of 0 ?
Please correct me if I'm wrong:
- a GObject holds a "ref_count"
- a GtkObject holds a "floating" (flag or bool or something) (along with
GObject's ref_count)
- calling g_object_ref on a simple GObject will "ref_count++;"
- calling g_object_ref on a GtkObject type of GObject will "if
(++ref_count == 1) floating = FALSE;"
- calling g_object_unref on a "floating" GtkObject will finalize
- calling g_object_unref on a GtkObject with a ref_count of one will
finalize (of course)
- a GtkWindow usualy "floats" its entire lifespan
Is this "floating" concept a new implementation or just
still around for legacy/compatability reasons ? If this is new;
what is the advantage of having a "floating state" along with
a reference count ?
Thank you for any input on this,
-Tristan
Havoc Pennington wrote:
On Tue, Nov 12, 2002 at 03:21:01PM -0500, Tristan Van Berkom wrote:
I _think_ that:
b = gtk_button_new_with_label("hello!");
G_OBJECT(GTK_WIDGET(b)->child)->ref_count == 1
b = gtk_button_new();
l = gtk_label_new("hello!");
gtk_container_add(b, l);
G_OBJECT(GTK_WIDGET(b)->child)->ref_count == 2
Nope; the initial refcount on gtk_label_new() is "floating" so is
adopted by the container in gtk_container_add(), thus no extra
reference is added.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]