summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dbus/qdbusmetaobject.cpp18
-rw-r--r--tools/qdbus/qdbus/qdbus.cpp11
2 files changed, 26 insertions, 3 deletions
diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp
index 5fe0589..6683505 100644
--- a/src/dbus/qdbusmetaobject.cpp
+++ b/src/dbus/qdbusmetaobject.cpp
@@ -169,6 +169,8 @@ QDBusMetaObjectGenerator::QDBusMetaObjectGenerator(const QString &interfaceName,
}
}
+Q_DBUS_EXPORT bool qt_dbus_metaobject_skip_annotations = false;
+
QDBusMetaObjectGenerator::Type
QDBusMetaObjectGenerator::findType(const QByteArray &signature,
const QDBusIntrospection::Annotations &annotations,
@@ -178,7 +180,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
result.id = QVariant::Invalid;
int type = QDBusMetaType::signatureToType(signature);
- if (type == QVariant::Invalid) {
+ if (type == QVariant::Invalid && !qt_dbus_metaobject_skip_annotations) {
// it's not a type normally handled by our meta type system
// it must contain an annotation
QString annotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName");
@@ -201,6 +203,20 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature,
return result; // unknown type is invalid too
result.name = typeName;
+ } else if (type == QVariant::Invalid) {
+ // this case is used only by the qdbus command-line tool
+ // invalid, let's create an impossible type that contains the signature
+
+ if (signature == "av") {
+ result.name = "QVariantList";
+ type = QVariant::List;
+ } else if (signature == "a{sv}") {
+ result.name = "QVariantMap";
+ type = QVariant::Map;
+ } else {
+ result.name = "QDBusRawType::" + signature;
+ type = -1;
+ }
} else {
result.name = QVariant::typeToName( QVariant::Type(type) );
}
diff --git a/tools/qdbus/qdbus/qdbus.cpp b/tools/qdbus/qdbus/qdbus.cpp
index 6ec8224..4e5cf9a 100644
--- a/tools/qdbus/qdbus/qdbus.cpp
+++ b/tools/qdbus/qdbus/qdbus.cpp
@@ -50,6 +50,8 @@
#include <QtDBus/QtDBus>
#include <private/qdbusutil_p.h>
+Q_DBUS_EXPORT extern bool qt_dbus_metaobject_skip_annotations;
+
static QDBusConnection connection(QLatin1String(""));
static bool printArgumentsLiterally = false;
@@ -99,7 +101,7 @@ static void printArg(const QVariant &v)
else if (arg.currentSignature() == QLatin1String("a{sv}"))
printArg(qdbus_cast<QVariantMap>(arg));
else
- printf("qdbus: I don't know how to display an argument of type '%s'\n",
+ printf("qdbus: I don't know how to display an argument of type '%s', run with --literal.\n",
qPrintable(arg.currentSignature()));
} else {
printf("%s\n", qPrintable(v.toString()));
@@ -311,7 +313,11 @@ static int placeCall(const QString &service, const QString &path, const QString
int id = QVariant::nameToType(types.at(i));
if (id == QVariant::UserType)
id = QMetaType::type(types.at(i));
- Q_ASSERT(id);
+ if (!id) {
+ fprintf(stderr, "Cannot call method '%s' because type '%s' is unknown to this tool\n",
+ qPrintable(member), types.at(i).constData());
+ return 1;
+ }
QVariant p;
QString argument;
@@ -435,6 +441,7 @@ static void printAllServices(QDBusConnectionInterface *bus)
int main(int argc, char **argv)
{
+ qt_dbus_metaobject_skip_annotations = true;
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
args.takeFirst();