PDA

View Full Version : Service Framework - out of proccess via DBus - invokeMethod with char problem



Piskvorkar
16th November 2010, 22:48
Hi,
I'm creating some simple client - service application. Using Qt Mobility 1.1, Qt 4.7 (qtsdk-201005). In my service class i've something as this:


...
public slots:
int sampleMethod(int par1, char par2, QString par3);

Than in client, when got service proxy object successfully using QServiceManager:


QServieManager manager;
...
QObject *serviceProxy = manager.loadInterface(...); // successfull
// now try invoke method
int ret = 0;
bool ok = QMetaObject::invokeMethod(serviceProxy, "sampleMethod", Q_RETURN_ARG(int,ret), Q_ARG(int,0), Q_ARG(char,'a'), Q_ARG(QString,"something"));

Everything seems ok, but the char parameter received in Service is incorrect (not 'a' and when try it again, the value seems to be random). Same for unsinged char, long, unsigned long, ... only int is ok. And maybe some Qt classes as QString, QDataTime are ok. But why not char?
I've even tried to run dbus-monitor and here it seems, that values are passed correctly, so maybe they are parsed from DBus packet in some incorrect way.

If I invoke the same method with the same parameter directly on the Service object, using invoke method, i works fine (sampleMethod on object is called with proper values)


MyServiceObject *service = new MyServiceObject();
invokeMethod(service, "sampleMethod", Q_RETURN_ARG(int,ret), Q_ARG(int,0), Q_ARG(char,'a'), Q_ARG(QString,"something"));


Thanks for ideas.

Piskvorkar
17th November 2010, 13:58
Maybe this is not the right place for asking about Qt Service. I will be happy even if somebody navigate me where I should post question. Or should I rather report a bug? I've tried to find some QtMobility related forum, but i didn't find it.

Here is what dbus-monitor displayed:
1. Client passes: int value == 0, char value == 2, QString value == "my text"


int32 0
variant struct {
array [
byte 99
byte 104
byte 97
byte 114
]
array [
byte 0
byte 0
byte 0
byte 131
byte 0
byte 2
]
}
string "my text"
method return sender=:1.256 -> dest=:1.257 reply_serial=16
int32 0

and now for char value == 0:


int32 0
variant struct {
array [
byte 99
byte 104
byte 97
byte 114
]
array [
byte 0
byte 0
byte 0
byte 131
byte 0
byte 0
]
}
string "my text"
method return sender=:1.256 -> dest=:1.257 reply_serial=16
int32 0


When I've a breakpoint in MyServiceObject::sampleMethod(int p1, char p2, const QString &p3), p1 and p3 (int and QString) are the same as passed by client, but p2 (char) is some random number. But according to dbus it seems that the value there is ok (last byte field changes). Maybe problem is in casting back from QVariant, I havn't found char support in QVariant class.