From 19cc92d170eaba83812be2abda15348ecfa2f072 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 7 Feb 2020 09:57:02 +0100 Subject: QV4Engine: Do not construct invalid QVariant If the provided typeHint is -1, it does not make sense to construct a QVariant of this type and to check whether it is appendable. Fixes: QTBUG-81945 Change-Id: I32cbb9e70e210a7eca8d55801c1783338d1173b7 Reviewed-by: Ulf Hermann --- tests/auto/qml/qjsvalue/tst_qjsvalue.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/auto/qml/qjsvalue') diff --git a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp index 95f554776f..cab4686c37 100644 --- a/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp +++ b/tests/auto/qml/qjsvalue/tst_qjsvalue.cpp @@ -1128,6 +1128,10 @@ void tst_QJSValue::toVariant() // array { + auto handler = qInstallMessageHandler([](QtMsgType type, const QMessageLogContext &, const QString &) { + if (type == QtMsgType::QtWarningMsg) + QFAIL("Converting QJSValue to QVariant should not cause error messages"); + }); QVariantList listIn; listIn << 123 << "hello"; QJSValue array = eng.toScriptValue(listIn); @@ -1145,8 +1149,9 @@ void tst_QJSValue::toVariant() QCOMPARE(array2.property("length").toInt(), array.property("length").toInt()); for (int i = 0; i < array.property("length").toInt(); ++i) QVERIFY(array2.property(i).strictlyEquals(array.property(i))); - } + qInstallMessageHandler(handler); + } } void tst_QJSValue::toQObject_nonQObject_data() -- cgit v1.2.3