Re: gobject weak references
- From: Sven Neumann <sven gimp org>
- To: murrayc usa net
- Cc: gtk-devel-list gnome org
- Subject: Re: gobject weak references
- Date: 18 Sep 2001 14:45:15 +0200
Hi,
Murray Cumming <Murray_Cumming betaresearch de> writes:
> 1.
> Is this an accurate description of the new gobject weak references
> mechanism?:
> It doesn't actually increase the refcount, so the object might be
> deleted, but you'll know if it does because it will call your callback
> function.
sounds good to me.
> 2.
> The GWeakNofify callback will have this signature:
> void weaknotify_callback(gpointer data, GObject *where_the_object_was);
> What is the second argument about?
it is the memory address of the GObject that has been destroyed. You should
never dereference this pointer since it does not point to a valid GObject
anymore, but there are cases where you need this pointer. One example is
that you have a list or hash of GObjects and you want to remove the pointer
from this list when the GObject gets destroyed. You can very simply
implement such a weak container by adding a weak reference to the GObject
whenever you add one to the list and have it removed from the list in the
weak notifier.
Salut, Sven
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]