Adding Glib GMainContext support to DBusGlib Bindings

Marcus Nascimento marcus.cps at
Fri Mar 11 06:15:03 PST 2011

On Fri, Mar 11, 2011 at 10:37 AM, Simon McVittie <
simon.mcvittie at> wrote:

> On Fri, 11 Mar 2011 at 10:24:21 -0300, Marcus Nascimento wrote:
> > I've been having some trouble running dbus glib (server or client) on a
> > GMainContext other than the default one.
> Your patch looks reasonable at first glance; if you want to add this
> functionality, please open an 'enhancement'-severity bug on
> to track it (or reuse an existing one if it would fix an existing bug). If
> possible we prefer patches in the format produced by git format-patch, so
> we
> can preserve attribution.
> Potentially-relevant bugs include:
I'll look for that as soon as I have some time available.

> The reason I'm not particularly enthusiastic about merging this is that
> GDBus
> (in GLib >= 2.26) is probably a better choice for new GObject D-Bus code,
> particularly in the presence of threads. dbus-glib has various design flaws
> and, in practice, mostly isn't thread-safe.
> If you're doing this for multi-threading support, please look at the list
> of
> dbus/dbus-glib bugs that mention threads and consider whether you really
> want
> to be doing that, and are able to debug the results...
That worries me out!
I'm designing a portable lib for embedded (and non-embedded) use.
It has 2 dbus clients receiving signals from 2 dbus servers.
I'm facing a lot of thread issues with glib-dbus.

The major one: I can't start the default GMainLoop inside the library. It
will cause a lot of trouble for apps using GMainLoop by themselves.
For instance: Using my lib with QT will cause some strange events to pop-up.

I tried to create a separate GMainContext to keep things contained and
separate from the rest of the world.
That requires that I create a separate GMainLoop and run it in it's own
However this loop won't dispatch events unless the default GMainLoop in
running too (and them I face the same problem described in the last

Long story short: Do you recommend moving on from glib-dbus to GDbus in this

Thanks very much for your answer.

>    S
> _______________________________________________
> dbus mailing list
> dbus at

Marcus Vinícius do Nascimento
Engenharia de Computação - EC03 - UNICAMP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the dbus mailing list