Results 1 to 3 of 3

Thread: C++ - QDbus in multithread system

  1. #1
    Join Date
    Nov 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default C++ - QDbus in multithread system

    Hi everyone,

    I cannot push my code but i'll try to explain it the easier I can.

    I have two objects of the same class (Block) thats inherit from Q_Object with a slot function (catchSignal(QString)), a signal emitted (finished()), and a main function (execute())

    This is the main call for :

    void Block::execute() {
    - allocate new QNetworkAccessManager, do a request and connect the finished(QNetworkReply *) signal to a QEventLoop's quit() function
    - connect QDBusConnection::sessionBus()'s particular signal (emit from a another program) to the catchSignal(Qstring) slot
    - connect the Block emitted signal (finished()) to another QEventLoop's slot (quit())
    - disconnect QDBusConnection::sessionBus() from the signal I wanted to listen to
    }

    void Block::catchSignal(QString str) {
    - must be called 6 times by each object
    - when its has been called 6 times ---> emit finished() signal
    }

    I run the execute function of my two objects in a separate thread (c++ thread) but I noticed that when the main thread finished before the other, I dont received all event in my object from 2nd thread, and this last blocks for infinity.

    I tried to see whats happening on DBUS with dbus-monitor under linux, all signal required are well send.

    Do u have any ideas ?

    If u need more detail about the program u can ask question

  2. #2
    Join Date
    Nov 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: C++ - QDbus in multithread system

    After trying to mocking my block thread ID == 0 its seems that DBUS sessions has having trouble in my thread id 1

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: C++ - QDbus in multithread system

    Your description doesn't really say which thread your objects live in.

    Are they created by the main thread? Have they be moved into the secondary thread?
    Is the secondary thread running an event loop?
    Is the D-Bus connection handled by the main thread?

    You should really post at least some code.

    Cheers,
    _

Similar Threads

  1. Multithread in multicore CPU
    By ^NyAw^ in forum General Discussion
    Replies: 12
    Last Post: 26th December 2017, 14:19
  2. Qt MultiThread Help
    By Halpha in forum Newbie
    Replies: 1
    Last Post: 8th August 2012, 14:59
  3. I don't quite understand this multithread example
    By HelloDan in forum Qt Programming
    Replies: 2
    Last Post: 9th April 2009, 08:58
  4. about multithread
    By Pang in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2007, 18:06
  5. Help me about multithread!
    By vql in forum Newbie
    Replies: 19
    Last Post: 8th February 2007, 15:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.