Re: General GTK Question : When to Free, when to unref, etc.



Hubert Sokolowski wrote:

On Fri, 12 Nov 2004 21:53:04 -0500
Setzer- <setzer sm-soft org> wrote:
Likely, when should source pointers be freed, with functions like gtk_list_store_set, g_locale_to_utf8, etc.
It isn't always clear what is being done with the stuff.

I've also been told to use ' g_object_unref ', yet I've never heard of

it in the tutorials, or anywhere else.
Is it important to use it? In which cases?
this should be written in the reference when to use g_object_unref.


There is an excellent explanation of reference counting in Tim-Philipp Müller's Tree View Tutorial: http://scentric.net/tutorial/sec-treeview.html#sec-treeview-connect-model-refcounting

Here's a partial quote from that page:

'Reference counting' means that an object has a counter that can be increased or decreased (ref-ed and unref-ed). If the counter is unref-ed to 0, the object is automatically destroyed. This is useful, because other objects or application programmers only have to think about whether they themselves are still using that object or not, without knowing anything about others also using it. The object is simply automatically destroyed when no one is using it any more.

Joe Zacky



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