GObject and floating reference count



Hello,

I'm a little bit confused about the explanation of the floating reference count.

The documentation says about GObject:
"The initial reference a GObject is created with is flagged as a floating reference. This means that it is not specifically claimed to be "owned" by any code portion."
http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#floating-ref

And about GtkObject:
"The most interesting difference between GtkObject and GObject is the "floating" reference count. A GObject is created with a reference count of 1, owned by the creator of the GObject. (The owner of a reference is the code section that has the right to call g_object_unref() in order to remove that reference.) A GtkObject is created with a reference count of 1 also, but it isn't owned by anyone;"
http://developer.gnome.org/doc/API/2.0/gtk/GtkObject.html

So, the part of GtkObject says GObject is owned by the creator and the docs about GObject itself says it isn't owned by anyone (until g_object_sink() is called).

Who is wrong here? Or maybe I unterstood something wrong...

Why I'm asking is because I don't know exactly if the following code needs a g_object_unref of the GtkListStore, which has as parent GObject and not GtkObject.

Code:
  GtkListStore *store;
  store = gtk_list_store_new(N_EDIT_TV_COLUMNS,
    G_TYPE_INT,
    G_TYPE_STRING,
    G_TYPE_STRING,
    G_TYPE_INT
  );

  gtk_tree_view_set_model(GTK_TREE_VIEW(tview), GTK_TREE_MODEL(store));

  // is this needed??
  g_object_unref(G_OBJECT(store));


Hannes




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