Hi,

On 07 Jan 2010,  aleksander.morg...@gmail.com wrote:
>Just made some changes in my code according to what I had 
>understood from your answers, but it seems I didn't catch all 
>of it right. Got an assert from sofia-sip when running it.
[...]
> root =  su_glib_root_create(NULL); ---> 1st reference to the GSource 
> internally created
> source = su_glib_root_gsource(root); --> 2nd reference of the GSource
> g_source_attach(source, glib_context); --> 3rd reference of the GSource 
> inside the GLib context

you are correct that the 2nd reference is not taken. So
the initial reference is the one taken by su_glib_root_create()
when the GSource is created.

So you need to:
 - call g_source_unref() once to free the reference taken
   by su_glib_root_create()
 - unref the glib mainloop to free the refence taken by 
   g_source_attach()
 - free the su root object (but will free any additional 
   references to the GSource but the refcount can be also
   zero)

>g_source_destroy(source); /* Unref-ed the reference which was in the GLib 
>context */
>g_source_unref(source); /* Unref-ed the reference I got with 
>su_glib_root_gsource() */

So the destroy is extra and instead you need to unref
the mainloop context.

>Is this second piece of code right? 

Yep, that's correct.

>If so, then the 
>documentation of su_glib_root_gsource() is pretty confusing, 
>as it says:
>"Note that you need to unref the GSource with g_source_unref() 
>before destroying the root object." Really seems you are 
>getting a new reference with su_glib_root_gsource() which you 
>later need to unref(), while this seems not true.

Agreed, this is fairly confusing. Basicly su_glib_root_create()
documentation should state:
""Note that you need to unref the GSource with g_source_unref() 
before destroying the root object. E.g. 
'g_source_unref(su_glib_root_gsource(root))'.""

Still confusing, but maybe less so.

br,
-- 
first.surn...@nokia.com (Kai Vehmanen)
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to