From 5d192deed9ef7289e44cd936576d98b3afa2601a Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 26 Jul 2013 17:11:19 +0200 Subject: Fix crash on qdbus when return type is a raw dbus type Assigning a -1 to type is going to make things crash since it basically means unresolved and when you try to access the string data go to a index that doesn't exist So what I do is save the return type in rawReturnType if it is a raw one and reassign the type to IsUnresolvedType | strings.enter(mm.rawReturnType) instead of -1 when "saving" the metaobject Task-number: QTBUG-32671 Change-Id: I67898dea8a1926eee80c16417e877ef4e22aa06b Reviewed-by: Thiago Macieira --- src/dbus/qdbusmetaobject.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 799c66f6f9..127cf6658c 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -75,6 +75,7 @@ private: QByteArray name; QVarLengthArray inputTypes; QVarLengthArray outputTypes; + QByteArray rawReturnType; int flags; }; @@ -276,6 +277,9 @@ void QDBusMetaObjectGenerator::parseMethods() mm.outputTypes.append(type.id); + if (i == 0 && type.id == -1) { + mm.rawReturnType = type.name; + } if (i != 0) { // non-const ref parameter mm.parameterNames.append(arg.name.toLatin1()); @@ -471,10 +475,14 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) int type; QByteArray typeName; if (i < 0) { // Return type - if (!mm.outputTypes.isEmpty()) + if (!mm.outputTypes.isEmpty()) { type = mm.outputTypes.first(); - else + if (type == -1) { + type = IsUnresolvedType | strings.enter(mm.rawReturnType); + } + } else { type = QMetaType::Void; + } } else if (i < mm.inputTypes.size()) { type = mm.inputTypes.at(i); } else { -- cgit v1.2.3