summaryrefslogtreecommitdiffstats
path: root/src/qdbus
diff options
context:
space:
mode:
authorDirk Mueller <mueller@kde.org>2013-01-04 17:40:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-07 13:37:57 +0100
commit0c22eb9d9d1a0b72622fdf16ebf60712336b449e (patch)
treec45bc74fd56d62c9d31add85d8e8132633403fd4 /src/qdbus
parent297291c732abbda6d185042553227178d3f7d879 (diff)
Try harder in matching the method signature
In cases where the Propertiesdialog has no specific Implementation for a dbus data type, it creates a regular QLineEdit. In such cases, qdbusviewer then tried to call the method with the arg set to a string instead of the real datatype (for example uint64), which usually does not work. We can be more clever and try to implicitely convert the user input to the right datatype, which makes the invocation succeed. Change-Id: Idbb5c667496e14922efb7d195e11fafbb880c61c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/qdbus')
-rw-r--r--src/qdbus/qdbusviewer/qdbusviewer.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qdbus/qdbusviewer/qdbusviewer.cpp b/src/qdbus/qdbusviewer/qdbusviewer.cpp
index 1d6429a59..c6d8f1faa 100644
--- a/src/qdbus/qdbusviewer/qdbusviewer.cpp
+++ b/src/qdbus/qdbusviewer/qdbusviewer.cpp
@@ -294,9 +294,17 @@ void QDBusViewer::callMethod(const BusSignature &sig)
args = dialog.values();
}
- // Special case - convert a value to a QDBusVariant if the
- // interface wants a variant
+ // Try to convert the values we got as closely as possible to the
+ // dbus signature. This is especially important for those input as strings
for (int i = 0; i < args.count(); ++i) {
+ QVariant a = args.at(i);
+ int desttype = types.at(i);
+ if (desttype < int(QMetaType::User) && desttype != int(QVariant::Map)
+ && a.canConvert(desttype)) {
+ args[i].convert(desttype);
+ }
+ // Special case - convert a value to a QDBusVariant if the
+ // interface wants a variant
if (types.at(i) == qMetaTypeId<QDBusVariant>())
args[i] = QVariant::fromValue(QDBusVariant(args.at(i)));
}