Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot receive response from DBus

Cannot receive response from DBus

Scheduled Pinned Locked Moved Solved General and Desktop
qdbusdbus
3 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Crindu
    wrote on 23 Jul 2018, 21:33 last edited by
    #1

    I'm creating a custom service and object using QDbus and I'm using D-feet for testing purposes. I noticed that if I put all code in the main class, all works fine, otherwise it crashes.
    This works, I can see the service and the object correctly created with d-feet:

    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        QDBusConnection session = QDBusConnection::sessionBus();
        QString myService = QString("test.example");
        QDBusObjectPath agentPath = QDBusObjectPath("/testagent");
        OrgBluezAgent1Interface* agent = new OrgBluezAgent1Interface(myService,agentPath.path(),session);
        Agent1Adaptor adaptor(agent);
        cout << "register service "<<boolalpha<<session.registerService(myService)<<endl;
        cout << "register object " <<boolalpha<<session.registerObject(agentPath.path(),agent)<<endl;
    
    
        //busTest b;
        return a.exec();
    }
    

    This is the not working version, in particular, D-feet crashes when I try to click on the service created with the following error: org.freedesktop.DBus.Error.NoReply: Message recipient disconnected from message bus without replying.

    busTest::busTest(QObject *parent)
        :   QObject(parent),bus(QDBusConnection::systemBus())
    {
        QDBusConnection session = QDBusConnection::sessionBus();
        QString myService = QString("test.example");
        QDBusObjectPath agentPath = QDBusObjectPath("/testagent");
        OrgBluezAgent1Interface* agent = new OrgBluezAgent1Interface(myService,agentPath.path(),session);
        Agent1Adaptor adaptor(agent);
        cout << "register service "<<boolalpha<<session.registerService(myService)<<endl;
        cout << "register object " <<boolalpha<<session.registerObject(agentPath.path(),agent)<<endl;
    }
    

    I'm also monitoring the dbus messages with dbus-monitor --session
    but I cannot find a suitable solution, it seems that something is destroyed in the busTest class and so I cannot receive the dbus response. Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Jul 2018, 21:36 last edited by
      #2

      Hi,

      Why are you getting both the system and session bus ?

      Your Agent1Adaptor object will be destroyed at the end of the constructor.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply 23 Jul 2018, 22:17
      1
      • S SGaist
        23 Jul 2018, 21:36

        Hi,

        Why are you getting both the system and session bus ?

        Your Agent1Adaptor object will be destroyed at the end of the constructor.

        C Offline
        C Offline
        Crindu
        wrote on 23 Jul 2018, 22:17 last edited by
        #3

        @SGaist You're right,I did not think about it! I have to remove the systemBus, I'm not using it in reality, it's part of the project that I found on Github. Ok then I can try to make it an instance variable of the class or similer. Thank you!

        1 Reply Last reply
        0

        3/3

        23 Jul 2018, 22:17

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved