summaryrefslogtreecommitdiff
path: root/src/webchannel/qmetaobjectpublisher.cpp
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2017-08-07 23:24:57 +0200
committerMilian Wolff <milian.wolff@kdab.com>2017-08-08 20:55:01 +0000
commitb5229df6a08a902b11a2fc9529af6385f4d985d5 (patch)
tree09c9b0ca5e16c317441ff62e2a5a5408ee64c423 /src/webchannel/qmetaobjectpublisher.cpp
parent01bd2b3ca88b42b9daac7cb00d196eb90d168570 (diff)
downloadqtwebchannel-b5229df6a08a902b11a2fc9529af6385f4d985d5.tar.gz
Do not crash on non-QVariant return types
Patch e354bdc5 introduced a regression that triggers a crash in Qt 5.9 when returning a type that is not implicitly convertible to QVariant, such as a QJsonValue, from an invoked method/slot. This patch fixes this situation and adds proper unit test coverage. Change-Id: Ib8cb0c96e7496bc8dc9a628245d7a44e4234aff0 Task-number: QTBUG-62045 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> Reviewed-by: Kai Dohmen <psykai1993@googlemail.com>
Diffstat (limited to 'src/webchannel/qmetaobjectpublisher.cpp')
-rw-r--r--src/webchannel/qmetaobjectpublisher.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp
index dcc589c..cfc6ad2 100644
--- a/src/webchannel/qmetaobjectpublisher.cpp
+++ b/src/webchannel/qmetaobjectpublisher.cpp
@@ -383,12 +383,12 @@ QVariant QMetaObjectPublisher::invokeMethod(QObject *const object, const int met
arguments[0], arguments[1], arguments[2], arguments[3], arguments[4],
arguments[5], arguments[6], arguments[7], arguments[8], arguments[9]);
} else {
- QGenericReturnArgument returnArgument(method.typeName(), returnValue.data());
-
// Only init variant with return type if its not a variant itself, which would
// lead to nested variants which is not what we want.
if (method.returnType() != QMetaType::QVariant)
returnValue = QVariant(method.returnType(), 0);
+
+ QGenericReturnArgument returnArgument(method.typeName(), returnValue.data());
method.invoke(object, returnArgument,
arguments[0], arguments[1], arguments[2], arguments[3], arguments[4],
arguments[5], arguments[6], arguments[7], arguments[8], arguments[9]);