DBus newbie

Thiago Macieira thiago at kde.org
Mon Sep 21 03:21:36 PDT 2009


Em Segunda-feira 21 Setembro 2009, às 10:40:35, você escreveu:
> Hi, I am new to DBus technology and have a problem. A learn from
> http://doc.trolltech.com/qq/qq20-dbus.html Here is my code:
> 
> class Animal : public QObject
> {
> 	Q_OBJECT
> 
> 	public:
> 	Animal() { mood = 0; }
> 
> 	public slots:
> 	void feed(void) {
> 		++mood;
> 		emit moodChanged(mood);
> 		return;
> 	}
> 	void shoutAt(void) {
> 		--mood;
> 		emit moodChanged(mood);
> 		return;
> 	}
> 
> 	int currentMood() const { return mood; }
> 
> 	signals:
> 	void moodChanged(int mood);
> 
> 	private:
> 	int mood;
> };
> 
> main.cpp file:
> QDBusConnection bus = QDBusConnection::sessionBus();
> bus.interface()->registerService("Farm");
> 
> Animal cat;
> 
> bus.registerObject("/animals/Dax", &cat, QDBusConnection::ExportAllSlots);
> 
> But when I try to feed my cat:
> QDBusConnection::sessionBus().call(QDBusMessage::createMethodCall("Farm",
>  "/animals/Dax", "", "feed"));
> 
> I get this error message:
> process 18995: arguments to dbus_message_new_method_call() were incorrect,
>  assertion "destination == NULL || _dbus_check_is_valid_bus_name
>  (destination)" failed in file dbus-message.c line 1073. This is normally a
>  bug in some application using the D-Bus library. QDBusConnection: error:
>  could not send message to service "Farm" path "/animals/Dax" interface ""
>  member "feed"
> 
> What is wrong? Thanks for any answers.

Please upgrade Qt. This kind of crash has been fixed.

But the problem is that the destination service name of "Farm" is not valid.

It needs to have at least one dot in the name.

-- 
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

Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14     San Francisco, California: Nov 2 - 4
      http://qt.nokia.com/qtdevdays2009
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20090921/33bfc553/attachment.pgp 


More information about the dbus mailing list