diff options
author | Albert Astals Cid <albert.astals@canonical.com> | 2013-07-26 17:11:19 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-30 09:22:42 +0200 |
commit | 5d192deed9ef7289e44cd936576d98b3afa2601a (patch) | |
tree | dfc11b7eddb518cc4af98cbdaa87010a8a426c8c /src/dbus | |
parent | f52e9b117284d5dd80dcd4503e57d4cb8a839ae1 (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus')
-rw-r--r-- | src/dbus/qdbusmetaobject.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
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<int, 4> inputTypes; QVarLengthArray<int, 4> 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 { |