Re: gobject ref and unref ?

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

 



That was pretty neat thanks.



On 11/10/09, Tadej Borovšak <tadeboro@xxxxxxxxx> wrote:
> Hello.
>
>> 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
> example.
>
> 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
>
>
> --
> Tadej Borovšak
> tadeboro.blogspot.com
> tadeboro@xxxxxxxxx
> tadej.borovsak@xxxxxxxxx
>


-- 
Regards,
~Sid~
I have never met a man so ignorant that i couldn't learn something from him
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux