summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDirk Mueller <mueller@kde.org>2013-01-04 13:45:24 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-29 07:32:45 +0100
commit8da495d38d8e5fe134fe5508144da68a3bb2d21c (patch)
tree7ee835a5bfaa3cb7e9101c82a7e2e9b2ceb1d75e /tools
parentfbc9134051c40f45ca606d204e000a4987ad8ff2 (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: I9e16be6e7c5209745f2fa0c32acf08a3c42178f1 (cherry-pick of qttools/0c22eb9d9d1a0b72622fdf16ebf60712336b449e) Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qdbus/qdbusviewer/qdbusviewer.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/qdbus/qdbusviewer/qdbusviewer.cpp b/tools/qdbus/qdbusviewer/qdbusviewer.cpp
index 843323844e..e937a358cd 100644
--- a/tools/qdbus/qdbusviewer/qdbusviewer.cpp
+++ b/tools/qdbus/qdbusviewer/qdbusviewer.cpp
@@ -279,9 +279,18 @@ 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(a.type())
+ && desttype < int(QMetaType::LastCoreType) && desttype != int(QVariant::Map)
+ && a.canConvert(QVariant::Type(desttype))) {
+ args[i].convert(QVariant::Type(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)));
}