Re: Widget ref-count on creation
- From: John Cupitt <jcupitt gmail com>
- To: Russell Shaw <rjshaw netspace net au>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Widget ref-count on creation
- Date: Tue, 22 Jun 2004 17:39:04 +0000
Widgets are created with a refcount of 1, but a "floating" flag too.
The first time another widget refs it, it clears the floating flag and
does not change the ref count.
http://developer.gnome.org/doc/API/2.0/gtk/GtkObject.html#gtk-object-sink
The idea is to save the programmer lots of annoying unrefs every time
an object is built and added to a container.
On Wed, 23 Jun 2004 03:23:57 +1000, Russell Shaw <rjshaw netspace net au> wrote:
Hi,
In the gtk tutorial:
http://www.gtk.org/tutorial/app-codeexamples.html#SEC-TICTACTOE
a composite widget is created with:
GtkWidget*
tictactoe_new ()
{
return GTK_WIDGET (g_object_new (tictactoe_get_type (), NULL));
}
The refcount on this object is 1 i assume.
In main.c, the widget is added to a container:
gtk_container_add (GTK_CONTAINER (window), ttt);
so i assume this increases the refcount to 2 (couldn't tell
by looking at gtk source). So, if the containing window is
destroyed, it will release its refcount. However, the ttt
widget will still have a refcount of 1 and hang around.
What is the correct way of handling the refcount on widget
creation?
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]