From 0c22eb9d9d1a0b72622fdf16ebf60712336b449e Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Fri, 4 Jan 2013 17:40:54 +0100 Subject: [PATCH] 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 --- src/qdbus/qdbusviewer/qdbusviewer.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qdbus/qdbusviewer/qdbusviewer.cpp b/src/qdbus/qdbusviewer/qdbusviewer.cpp index 1d6429a..c6d8f1f 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()) args[i] = QVariant::fromValue(QDBusVariant(args.at(i))); } -- 2.7.4