From 8da495d38d8e5fe134fe5508144da68a3bb2d21c Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Fri, 4 Jan 2013 13:45:24 +0100 Subject: 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 --- tools/qdbus/qdbusviewer/qdbusviewer.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'tools') 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()) args[i] = QVariant::fromValue(QDBusVariant(args.at(i))); } -- cgit v1.2.3