Re: gobject ref and unref ?


> Is there any documentation available for it ? as to when to ref and
> unref it based upon the api's ?

You don't need to know those things, since object's total reference
count is of no importance to you. All you need to do is keep track of
your own references on an object. Let me explain this based on your

When you create new store for GtkTreeView (be it GtkListStore or
GtkTreeStore), you get an object that has a reference count of 1 and
this reference is owned by you and is the only thing that is keeping
you newly created object "alive". Now you add this store to the
GtkTreeView, which is from now "co-owner" of the store. I
intentionally co-owner in last sentence, because you don't need to
know what exactly GtkTreeView does to claim ownership (it can add 1, 2
or 10 references if it needs to). If you don't need created store for
anything else, you can now remove your own reference from it, which
essentially makes GtkTreeView the only "owner" of the store.

You can see that no explicit reference counting wizardry is needed to
properly count references. Just make sure your own references are
removed when you don't need an object to stick around.


Tadej Borovšak
tadeboro gmail com
tadej borovsak gmail com

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