Re: freeing GTK+ memory



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> See
> http://library.gnome.org/devel/gtk/stable/GtkObject.html#GtkObject.description

thanks, that's what I wanted to know. But I have some more questions:

1. Does the behaviour (about 'floating' references) also apply for (gtk+) objects created with g_object_new instead of
gtk_object_new?

2. The GtkObject documentation says: "Never call g_object_unref() unless you have previously called g_object_ref() ..",
however in the "HelloWorld" example of the TreeView tutorial [1] Tim writes:

  GtkTreeModel        *model;

  ...

  model = create_and_fill_model (); /* function creates a ListStore with gtk_list_store_new */

  gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);

  /* The tree view has acquired its own reference to the
   *  model, so we can drop ours. That way the model will
   *  be freed automatically when the tree view is destroyed */

  g_object_unref (model);
...

Is this correct? Or it is safe to do so since gtk_tree_view_set_model implicit g_object_ref() call?


Is there a document(ation) which describes more precisely how Gtk+/Glib manages the memory of the objects  (I mean about
those 'floating' references, etc)?

Thanks

Regards
Pablo



[1] http://scentric.net/tutorial/ch-treeview.html#sec-TreeView-HelloWorld

Pablo Yánez Trujillo
http://klingsor.informatik.uni-freiburg.de/
My public key: http://klingsor.informatik.uni-freiburg.de/gpg/supertux.asc


Chris Vine wrote:
> On Fri, 17 Oct 2008 01:48:18 +0200
> Pablo Yanez Trujillo <yanezp informatik uni-freiburg de> wrote:
> [snip]
>> One question remains unanswered though: if I use gtk_widget_destroy
>> then the memory for this widget (and children if they exist) will be
>> (automatically) freed by Gtk/Glib? Sometimes you really want to
>> destroy a window/widget/whatever you don't need anymore.
> 
> See
> http://library.gnome.org/devel/gtk/stable/GtkObject.html#GtkObject.description 
> 
> This does not apply to pure GObjects not derived from GInitiallyUnowned.
> 
> Chris
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkj5CuAACgkQDzf8xo+0xRVAcgCgk5lLwCUE/6a7awCp4THtpc9g
qakAoKI0mhdtQXpRN/D2PPw3L1Yy3mg4
=x5gw
-----END PGP SIGNATURE-----


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