diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-02-10 12:26:56 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-02-17 15:02:14 (GMT) |
commit | cc2db7a49c9208a00a913f7c4a410009814a5580 (patch) | |
tree | 9f469afbdfd100d304eb4b943c3df67e15822f08 | |
parent | 5b53b44a2be8478adeee4a9e4796345828ad0248 (diff) | |
download | Qt-cc2db7a49c9208a00a913f7c4a410009814a5580.zip Qt-cc2db7a49c9208a00a913f7c4a410009814a5580.tar.gz Qt-cc2db7a49c9208a00a913f7c4a410009814a5580.tar.bz2 |
QtDBus meta object: keep methods, signals and props with unknown types
Use VoidStar as the metatype, with an unknown type called
"QDBusRawType". The actual D-Bus type is saved as an hex value as a
template parameter.
D-Bus type Qt type comment
h QDBusRawType<0x68>* Unix file descriptors
~ QDBusRawType<0x7e>* invalid type
ai QDBusRawType<0x6169>* array of int32
a{i(ssy)} QDBusRawType<0x617b6928737379297d>*
Note that the number in the template doesn't have to be valid. The
QDBusRawType class doesn't exist anyway.
I thought of just leaving the raw D-Bus type there, but who knows what
kind of things can appear there, like other '>' (which may cause
problems for anything trying to parse the meta object later).
Task-number: QTBUG-17476
-rw-r--r-- | src/dbus/qdbusmetaobject.cpp | 21 | ||||
-rw-r--r-- | src/dbus/qdbusxmlparser.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 11 |
3 files changed, 23 insertions, 10 deletions
diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 6683505..df8bc1d 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -193,14 +193,19 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature, QByteArray typeName = annotations.value(annotationName).toLatin1(); // verify that it's a valid one - if (typeName.isEmpty()) - return result; // invalid - - type = QVariant::nameToType(typeName); - if (type == QVariant::UserType) - type = QMetaType::type(typeName); - if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type)) - return result; // unknown type is invalid too + if (!typeName.isEmpty()) { + // type name found + type = QVariant::nameToType(typeName); + if (type == QVariant::UserType) + type = QMetaType::type(typeName); + } + + if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type)) { + // type is still unknown or doesn't match back to the signature that it + // was expected to, so synthesize a fake type + type = QMetaType::VoidStar; + typeName = "QDBusRawType<0x" + signature.toHex() + ">*"; + } result.name = typeName; } else if (type == QVariant::Invalid) { diff --git a/src/dbus/qdbusxmlparser.cpp b/src/dbus/qdbusxmlparser.cpp index 413ebbe..3feedde 100644 --- a/src/dbus/qdbusxmlparser.cpp +++ b/src/dbus/qdbusxmlparser.cpp @@ -240,7 +240,6 @@ QDBusXmlParser::interfaces() const qDBusParserError("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", qPrintable(propertyData.type), qPrintable(ifaceName), qPrintable(propertyName)); - continue; } QString access = property.attribute(QLatin1String("access")); diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index 37e1c64..39f0677 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -350,7 +350,16 @@ void tst_QDBusInterface::introspectUnknownTypes() "com.trolltech.QtDBus.MyObjectUnknownTypes"); const QMetaObject *mo = iface.metaObject(); - QVERIFY(mo->indexOfMethod("regularMethod()") != -1); + QVERIFY(mo->indexOfMethod("regularMethod()") != -1); // this is the control + QVERIFY(mo->indexOfMethod("somethingHappened(QDBusRawType<0x7e>*)") != -1); + + QVERIFY(mo->indexOfMethod("ping(QDBusRawType<0x7e>*)") != -1); + int midx = mo->indexOfMethod("ping(QDBusRawType<0x7e>*)"); + QCOMPARE(mo->method(midx).typeName(), "QDBusRawType<0x7e>*"); + + QVERIFY(mo->indexOfProperty("prop1") != -1); + int pidx = mo->indexOfProperty("prop1"); + QCOMPARE(mo->property(pidx).typeName(), "QDBusRawType<0x7e>*"); } void tst_QDBusInterface::callMethod() |