PDA

View Full Version : Help with QtDBus signals



zuck
2nd April 2009, 16:50
Hi, I need to send signals over a dbus connection.

This is the remote object adaptor code:

pkcontextbardbusadaptor.h


#include <QtDBus>
#include "pkcontextbar.h"

class pkContextBarDBusAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "it.card-tech.pk.contextBar")

protected:
pkContextBar* m_owner;

public:
pkContextBarDBusAdaptor(pkContextBar* owner);

public slots:
int addAction(const QString& text);
void clear();

private slots:
void actionTriggered(QAction* action);

signals:
void triggered(int);
};


pkcontextbardbusadaptor.cpp


#include "pkcontextbardbusadaptor.h"

pkContextBarDBusAdaptor::pkContextBarDBusAdaptor(p kContextBar* owner)
: QDBusAbstractAdaptor(owner),
m_owner(owner)
{
this->connect(m_owner, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*)));
}

/** ... CUT ... **/

void pkContextBarDBusAdaptor::actionTriggered(QAction* action)
{
QList<QAction*> actions = m_owner->actions();
int action_count = actions.count();

for (int i = 0; i < action_count; i++)
{
if (actions[i] == action)
{
emit triggered(i); // <--- Here is the problem.
break;
}
}
}


This is the pkContextBar constructor body, where I attach the dbus adaptor to the concrete object:

pkcontextbar.cpp


#include "pkcontextbar.h"
#include "pkcontextbardbusadaptor.h"

pkContextBar::pkContextBar(QWidget* parent)
: QMenuBar(parent),
m_ui(new Ui::pkContextBar)
{
m_ui->setupUi(this);

new pkContextBarDBusAdaptor(this);
}


The object is registered on the dbus in the main application body:



pkContextBar* context_bar = new pkContextBar(m_desktop);
QDBusConnection bus = QDBusConnection::sessionBus();
bus.registerService("it.card-tech.pk.server");
bus.registerObject("/desktop/contextBar", context_bar);


When the pkContextBarDBusAdaptor::actionTriggered is invoked, the triggered signal emission fails and returns this error message:


process 16161: arguments to dbus_message_new_signal() were incorrect, assertion "_dbus_check_is_valid_interface (interface)" failed in file dbus-message.c line 1162.
This is normally a bug in some application using the D-Bus library.
QDBusConnection: Could not emit signal it.card-tech.pk.contextBar.triggered

Help me, please :(

talk2amulya
2nd April 2009, 17:52
i think you have registered the wrong service, it should be it.card-tech.pk.contextBar..u have used it.card-tech.pk.server...

zuck
4th April 2009, 14:37
The problem is in service and interface names: the "-" character is not allowed ;)

pierrem2000
20th May 2009, 05:33
I having the exact same issue:

process 10907: arguments to dbus_message_new_signal() were incorrect, assertion "interface != NULL" failed in file dbus-message.c line 1159.
This is normally a bug in some application using the D-Bus library.

This occurs when the signal is "emitted".

And I'm not using "-" in my service name...

Anybody has ideas of what could cause this?