Unknown Object Path even after registering object in QDbus



  • I created an Interface header file and called qt5_generate_dbus_interface() from cmake to get a .xml file.
    Then I generated an adaptor from this .xml file by calling qt_add_dbus_adaptor().
    In the Interface cpp file's ctor, I binded the adaptor generated and called registerObject() and registerService() with valid arguments.
    The booleans for both returned true.
    However, I get the following error:

    Call to object / <My Service>: org.freedesktop.DBus.Error.UnknownObject (No such object path '/') failed

    Calling on the path, that I registered object at, also causes the same error.

    Some Cmake code

    set(dbus_SRCS org.kde.kdenow.Flight.xml)
     +
     +qt5_generate_dbus_interface(flightinterface.h
     +                            org.kde.kdenow.Flight.xml
     +                            OPTIONS -M
     +                            )
     +
     +qt5_add_dbus_adaptor(dbus_SRCS
     +                     ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kdenow.Flight.xml
     +                     flightinterface.h
     +                     FlightInterface
     +                    )
    
    

    flightinterface.h

    class FlightInterface : public QObject
    {
            Q_OBJECT
            Q_CLASSINFO("D-Bus Interface", "org.kde.kdenow.Flight");
    
        public:
            explicit FlightInterface(QObject* parent = 0);
            void setMap(QVariantMap& map);
    
        public Q_SLOTS:
            QVariantMap getMap();
    
        private:
            QVariantMap m_map;
    };
    

    flightinterface.cpp

    FlightInterface::FlightInterface(QObject* parent): QObject(parent)
    {
        new FlightAdaptor(this);
        QDBusConnection dbus = QDBusConnection::sessionBus();
        bool obOk = dbus.registerObject("/Flight", this);
        bool serOk= dbus.registerService("org.kde.kdenow.Flight");
        if (!obOk) {
            qDebug() << "Could not register Object";
        }
        else {
            qDebug() << "Registered object at path";
        }
        if (!serOk) {
            qDebug() << "Could not register service";
        }
        else {
            qDebug() << "Registered Service";
        }
    }
    
    void FlightInterface::setMap(QVariantMap& map)
    {
        m_map = map;
        qDebug() << m_map;
    }
    
    QVariantMap FlightInterface::getMap()
    {
        return m_map;
    }
    

    I setMap() from some other valid code.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.