Hooking the QT Main Loop

Thiago Macieira thiago at kde.org
Mon Apr 16 14:00:22 PDT 2007


David Zeuthen wrote:
>On Mon, 2007-04-16 at 22:33 +0200, Thiago Macieira wrote:
>> David Zeuthen wrote:
>> >How does this work if I'm a library and I ask the application to
>> >integrate one of my DBusConnection objects into the applications main
>> >loop? (it might be a private connection)
>>
>> You don't. QtDBus doesn't handle third-party connections. It only
>> handles its own.
>>
>> If you're a library using D-Bus and you want to work with Qt, you must
>> use QDBusConnection and not DBusConnection.
>
>I'm just curious but is there a specific technical reason why this is
>so? 

It's simpler than you might think: I had never conceived the case.

So, as a consequence, the code I wrote doesn't have provisions for that 
use-case.

Originally, QtDBus did use the shared session DBusConnection. But then, at 
some point, we started using a private connection.

>I mean, there are libraries in the wild working like this [1].. and 
>I can think of valid reasons for people to do this.
>
>Of course, people can always just write their own implementation of
>dbus_connection_setup_qt4_main() - it just seems.. rather weird.. and a
>bit asocial.. that you don't provide this at all. For example, how do
>you expect people to use Qt and provide a library using D-Bus that
>allows you to use a foreign main loop (that is not necessarily glib or
>Qt)?

See my other emails to this list about "who handles the mainloop 
integration", etc. The conclusion so far is, "the library must rely on 
the application author properly initialising the mainloop integration, 
whatever it is". Libraries must therefore not attempt to call any 
initialisation functions.

In the special case of QtDBus: it handles its own connections and nothing 
more. Therefore, you may not use DBusConnection directly, in any of the 
libraries being used in a Qt-based application.

That is the current state of things.

I can implement such a method for Qt 4.4.0. That is, the next release 
after the one that will be out in a few months.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    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: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/dbus/attachments/20070416/8d81a985/attachment.pgp


More information about the dbus mailing list