diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-01-16 16:28:31 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-01-19 09:57:27 +0000 |
commit | 533f9591595c3933ac56a3b3f4422a8aa821cb00 (patch) | |
tree | 9958668c1642d95406d1bdc4f2c8591e28b0d86a /tests | |
parent | dc5efbfd03e00c075ff90a8366d341ee15f0b5be (diff) |
Fix support for QJSValue as C++ signal parameter type, part 2
After commit 0e3380f9c6ab6e3ea7398caccf5aa84f1575f1cd we wouldn't crash
anymore, if QJSValue::UndefinedValue was provided as value for a
QJSValue C++ signal parameter. However that was not a complete fix for
the regression of commit aa869cbb06bcf005e238059a2cb0205947ff0b5f, as
other primitive values stored in QJSValue as QVariant were not
converted, so for example QJSValue(42). So let's fix this once and for
all by using QJSValuePrivate::valueForData, that handles all types of
QJSValuePrivate encodings.
Task-number: QTBUG-58133
Change-Id: Ib7c0461b18df6260ccd4bce729ae2348281eb7f3
Reviewed-by: Arnaud Vrac <avrac@freebox.fr>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 89c6bee139422b17534f79129eea2820d2ce952e)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml index 676593096c..54d29dfc94 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml @@ -16,5 +16,11 @@ MyQmlObject onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton) - onQjsValueEmittingSignal: {} + property bool emittedQjsValueWasUndefined + property int emittedQjsValueAsInt + + onQjsValueEmittingSignal: { + emittedQjsValueWasUndefined = value === undefined; + emittedQjsValueAsInt = value + } } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index b4d0e679ae..491e62f1d2 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1401,7 +1401,6 @@ void tst_qqmlecmascript::signalParameterTypes() QVERIFY(object != 0); emit object->basicSignal(); - emit object->qjsValueEmittingSignal(QJSValue()); QCOMPARE(object->property("intProperty").toInt(), 10); QCOMPARE(object->property("realProperty").toReal(), 19.2); @@ -1410,6 +1409,12 @@ void tst_qqmlecmascript::signalParameterTypes() QVERIFY(object->property("enumProperty") == MyQmlObject::EnumValue3); QVERIFY(object->property("qtEnumProperty") == Qt::LeftButton); + emit object->qjsValueEmittingSignal(QJSValue()); + QVERIFY(object->property("emittedQjsValueWasUndefined").toBool()); + emit object->qjsValueEmittingSignal(QJSValue(42)); + QVERIFY(!object->property("emittedQjsValueWasUndefined").toBool()); + QCOMPARE(object->property("emittedQjsValueAsInt").value<int>(), 42); + delete object; } |