From 15f8bc1f6ee94b84bebbd06de9db3ceacecad24d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 29 Jan 2014 12:35:43 -0800 Subject: [PATCH] Also register complex D-Bus types when running under qdbus When running inside qdbus, we generate the meta objects a little differently. Previously, for unknown types we'd simply have a -1 as the type ID in the meta object, but this doesn't work in Qt 5 (has apparently never worked). So simply register a type with the metatype system and let QMetaObject do its thing. [ChangeLog][qdbus]Fixed a bug that caused the qdbus tool to crash when trying to display remote interfaces that had complex types without a matching base Qt type. Task-number: QTBUG-36524 Change-Id: Ifef65b340dc89d3295ed6ef00f2dcc60849ecb02 Reviewed-by: Frederik Gladhorn --- src/dbus/qdbusmetaobject.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 13c538bb59..392eac6081 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -128,12 +128,7 @@ 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, - const char *direction, int id) +static int registerComplexDBusType(const char *typeName) { struct QDBusRawTypeHandler { static void destroy(void *) @@ -159,6 +154,22 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature, } }; + return QMetaType::registerNormalizedType(typeName, QDBusRawTypeHandler::destroy, + QDBusRawTypeHandler::create, + QDBusRawTypeHandler::destruct, + QDBusRawTypeHandler::construct, + sizeof(void *), + QMetaType::MovableType, + 0); +} + +Q_DBUS_EXPORT bool qt_dbus_metaobject_skip_annotations = false; + +QDBusMetaObjectGenerator::Type +QDBusMetaObjectGenerator::findType(const QByteArray &signature, + const QDBusIntrospection::Annotations &annotations, + const char *direction, int id) +{ Type result; result.id = QVariant::Invalid; @@ -195,13 +206,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature, // type is still unknown or doesn't match back to the signature that it // was expected to, so synthesize a fake type typeName = "QDBusRawType<0x" + signature.toHex() + ">*"; - type = QMetaType::registerType(typeName, QDBusRawTypeHandler::destroy, - QDBusRawTypeHandler::create, - QDBusRawTypeHandler::destruct, - QDBusRawTypeHandler::construct, - sizeof(void *), - QMetaType::MovableType, - 0); + type = registerComplexDBusType(typeName); } result.name = typeName; @@ -217,7 +222,7 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature, type = QVariant::Map; } else { result.name = "QDBusRawType::" + signature; - type = -1; + type = registerComplexDBusType(result.name); } } else { result.name = QMetaType::typeName(type);