Web lists-archives.com

g_main_context_pending helps to properly clean the context's sources




Hello guys,

I'm working on a GTK/Glib/Gio application and I use a separate MainLoop for some dbus communication. 

But I observed that a file descriptor was laking in my application. 

After few tries, I solved my leak by the following code : 

g_main_loop_unref(self->loop);
g_main_context_pop_thread_default(context);

//Is seems necessary to avoid fd leak
g_main_context_pending(context);

g_main_context_acquire(context);
g_main_context_dispatch(context);
g_main_context_release(context);
//Is seems necessary to avoid fd leak

if (g_main_context_pending(context)) {
g_warning("AstLive : Has pending sources");
}

g_main_context_unref(context);

The difference is the usage of g_main_context_pending. I can find any logical explanation of this, so does anyone can explain to me, why with the two call to g_main_context_pending my file descriptor is closed, and without it leaks ?

Thx in advance.

 
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list