g_main_context_pending helps to properly clean the context's sources
- From: Adrien Schwartzentruber <adrien schwartzentruber gmail com>
- To: gtk-list gnome org
- Subject: g_main_context_pending helps to properly clean the context's sources
- Date: Wed, 6 Jan 2016 15:48:51 +0100
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]