diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-01-13 13:31:35 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-01-14 22:00:50 +0000 |
commit | 600951e6d8a95e172439e347523aab1654c33135 (patch) | |
tree | 672d8ed69df5d483f005996edf6f7f0c0fb9eee1 /src | |
parent | 2c6bd4569878e9248311a7557661304e60a62878 (diff) |
Fix crash when C++ QJSValue parameterized signal interacts with JS
When converting the parameters of a C++ signal to JS values to provide
to a signal handler written in JS, the conversion of a QJSValue to a
QV4::Value* may yield a null pointer in case of a default constructed
QJSValue for example. This is a regression from commit
aa869cbb06bcf005e238059a2cb0205947ff0b5f and we must check for this.
Task-number: QTBUG-58133
Change-Id: I528b606b2851dfb3072e54902bd8843d31571a55
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 0e3380f9c6ab6e3ea7398caccf5aa84f1575f1cd)
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlboundsignal.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index a6fdf60c86..d8d8d28f3a 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -219,7 +219,10 @@ void QQmlBoundSignalExpression::evaluate(void **a) // for several cases (such as QVariant type and QObject-derived types) //args[ii] = engine->metaTypeToJS(type, a[ii + 1]); if (type == qMetaTypeId<QJSValue>()) { - callData->args[ii] = *QJSValuePrivate::getValue(reinterpret_cast<QJSValue *>(a[ii + 1])); + if (QV4::Value *v4Value = QJSValuePrivate::getValue(reinterpret_cast<QJSValue *>(a[ii + 1]))) + callData->args[ii] = *v4Value; + else + callData->args[ii] = QV4::Encode::undefined(); } else if (type == QMetaType::QVariant) { callData->args[ii] = scope.engine->fromVariant(*((QVariant *)a[ii + 1])); } else if (type == QMetaType::Int) { |