Widget ref-count on creation



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?



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]