[Qt-interest] QtDBus and Threads

Thiago Macieira thiago at kde.org
Mon Mar 1 22:48:14 CET 2010


Em Segunda-feira 1. Março 2010, às 21.24.19, Will Rutherdale (rutherw) 
escreveu:
> Hi.
> 
> I tried deriving a class from QObject and exposing an instance to dbus
> using QDBusConnection::registerObject().  I have done this lots of
> times, but this time was different:  I had moved the object to a
> different thread.
> 
> It didn't work.  When I tried looking at it using qdbus, that program
> got stuck.
> 
> The idea here was to be able to expose methods of an object not on the
> main thread to dbus.  That way it could do work and not tie up the event
> loop for the main thread.
> 
> Anyone know if this is supposed to work?  Or is QtDBus usage restricted
> to the main thread?
> 
> I am currently using Qt 4.5.

Yes, it's supposed to work.

Objects outside the main thread can be registered and used, no problem. 
However, the thread where those objects live must be running an event loop 
too. Is that your case?

If not, can you post an all-thread backtrace of the point when the program is 
stuck/frozen?

PS: I had some race-condition fixes in 4.5 and 4.6. Please be sure to use at 
least 4.5.3, but 4.6.2 is recommended.

-- 
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.qt-project.org/pipermail/qt-interest-old/attachments/20100301/a2f82633/attachment.bin 


More information about the Qt-interest-old mailing list