Re: newbie question about g_object unref()
- From: David NeÄas <yeti physics muni cz>
- To: N James Bridge <james xmas demon co uk>
- Cc: gtk-app-devel <gtk-app-devel-list gnome org>
- Subject: Re: newbie question about g_object unref()
- Date: Fri, 19 Nov 2010 14:36:17 +0100
On Fri, Nov 19, 2010 at 01:21:44PM +0000, N James Bridge wrote:
Thanks for all your contributions. I have now found G_IS_OBJECT(), which
is obviously the way to test whether the memory has been released or
not.
It obviously ISN'T.
If the memory was released then the argument is no longer a valid
GTypeInstance pointer as required (see the documentation).
If you want to nullify a pointer when you release your reference (which
I also find often useful as once you released your reference you may not
be longer sure the object exists at all) you should use a macro for
that, I use one defined approximately
do { if (obj) { g_object_unref(obj); (obj) = NULL; } } while (0)
which, beside nullifying the pointer, is idempotent and can also be
freely used on NULL pointer.
Yeti
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]