DBusConnection* from a QDbusConnection

Thiago Macieira thiago at kde.org
Thu Sep 30 01:48:09 PDT 2010


On Thursday 30. September 2010 09.34.40 maxprofitisback wrote:
> Thiago Macieira wrote:
> > On Wednesday 29. September 2010 15.59.49 maxprofitisback wrote:
> >> Hi,
> >> 
> >> Is it possible to get a DBusConnection from a QDbusConnection?
> > 
> > No.
> 
> In case of a Qt application which has a pool of
> QDbusConnection::sessionBus() connections for communicating with

It's not a pool. It's just one connection (one QDBusConnection, wrapping one 
DBusConnection).

> external components and has to use too an existing "client API" written
> with DBus-GLib bindings for communicating with other components.
> This "client API" use a separate sessionBus from the pool of connection
> of the Qt application.

Correct.

> How can I avoid DBus threading issues between the pool of connection and
>   the DBus-Glib client API ?

What threading issues are you talking about? Note that dbus-glib is not 
considered thread-safe.

If you mean the reentrancy issue of calling back to yourself, there are two 
ways: 1) don't do it. You must know that the call will route back to the 
current program and you must instead not do the call via D-Bus

or 2) make it a non-blocking (asynchronous) call.

> I was thinking of reusing somehow a sessionBus created from the pool of
> connections within the DBus-Glib client API ...

You can't do that. QtDBus must reserve the connection to itself due to the 
many assumptions about the state of the connection, the objects exposed and 
where messages go. Some of these assumptions are in place due threading issues 
and reentrancy issues.

If your application is constrained for resources (e.g., low-powered device 
where opening many D-Bus connections is a non-negligible penalty), the only 
advice I can give you is to skip one binding or the other, and use a single 
one for all your D-Bus needs.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20100930/1e604d19/attachment.pgp>


More information about the dbus mailing list