Re: GObject and floating reference count
- From: David Nečas (Yeti) <yeti physics muni cz>
- To: gtk-app-devel-list gnome org
- Subject: Re: GObject and floating reference count
- Date: Wed, 31 May 2006 16:14:57 +0200
On Wed, May 31, 2006 at 11:52:12AM +0200, Hannes Mayr wrote:
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...
It seems the GObject documentation is wrong (or at least
misleading) and it in fact talks about GInitiallyUnowned
which behaves like GtkObject always did.
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));
Yes, it is needed.
Yeti
--
Anonyms eat their boogers.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]