Re: Differences beetwen ref and weak ref
- From: "David Necas (Yeti)" <yeti physics muni cz>
- To: Uzytkownik <uzytkownik2 gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Differences beetwen ref and weak ref
- Date: Tue, 17 Jan 2006 20:15:18 +0100
On Tue, Jan 17, 2006 at 05:35:33PM +0000, Uzytkownik wrote:
I'm so sorry - when should I use weak reference?
Weak reference is a method to get notified that an object
was destroyed. Maybe it is better to not think about them
as about references at all.
When you take a [real] reference on an object, its refcount
increases and it will not be destroyed even if everything
else releases its references -- because of your reference.
Sometimes you want to keep a pointer to an object while not
preventing it from destruction. If you simply removed the
g_object_ref(), you'd have a pointer, but you would not know
whether it is still valid. So you use a weak reference/weak
pointer.
Yeti
--
That's enough.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]