Re: newbie question about g_object unref()

2010-11-19 Thread Luis Lopez
El 19/11/10 14:36, David Nečas escribió: 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

Re: newbie question about g_object unref()

2010-11-19 Thread David Nečas
On Fri, Nov 19, 2010 at 01:21:44PM +, 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

Re: newbie question about g_object unref()

2010-11-19 Thread N James Bridge
On Thu, 2010-11-18 at 22:11 +, N James Bridge wrote: > It seems that g_object_unref (ptr) doesn't set ptr to NULL when it frees > the allocated memory. Have I got something wrong here? Do I have to do > it explicitly? > Thanks for all your contributions. I have now found G_IS_OBJECT(), which i

Re: newbie question about g_object unref()

2010-11-18 Thread Jannis Pohlmann
On Thu, 18 Nov 2010 22:11:45 + N James Bridge wrote: > It seems that g_object_unref (ptr) doesn't set ptr to NULL when it > frees the allocated memory. Have I got something wrong here? Do I > have to do it explicitly? You can do it explicitely by using g_object_add_weak_pointer (your_obje

Re: newbie question about g_object unref()

2010-11-18 Thread Leandro Pereira
Nader Morshed, On Thu, Nov 18, 2010 at 8:21 PM, Nader Morshed wrote: > > #define G_OBJECT_UNREF_AND_NULLIFY(ptr) { \ >        g_object_unref(ptr); \ >        (ptr) = NULL; \ > } > Not a good idea: the object may still hold a reference, and nullifying the pointer would probably nullify the only w

Re: newbie question about g_object unref()

2010-11-18 Thread Michael Cronenworth
N James Bridge wrote: It seems that g_object_unref (ptr) doesn't set ptr to NULL when it frees the allocated memory. Have I got something wrong here? Do I have to do it explicitly? The official documentation[1] does not mention anything about setting the pointer to NULL. Did you read something

Re: newbie question about g_object unref()

2010-11-18 Thread Nader Morshed
As it only takes a pointer, and not a pointer to a pointer (&ptr), there's no way for g_object_unref to set the original pointer variable to NULL, you'd have to nullify it yourself, either through g_pointer_nullify or just ptr = NULL. If you want you can wrap the two in a macro, but as far as I