From d8fe3dfde9c6f73c49c8e69b41d77710f8dc463a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 12 Nov 2013 11:01:06 +0100 Subject: Don't crash when trying to assign to null.prop Fixes a regression introduced during the exception handling refactoring. Task-number: QTBUG-34544 Change-Id: Ib751274d759030db3e5d3b1380b30dc07ec85f83 Reviewed-by: Simon Hausmann --- .../qml/qqmlecmascript/data/setPropertyOnNull.qml | 5 +++++ .../qqmlecmascript/data/setPropertyOnUndefined.qml | 5 +++++ .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 tests/auto/qml/qqmlecmascript/data/setPropertyOnNull.qml create mode 100644 tests/auto/qml/qqmlecmascript/data/setPropertyOnUndefined.qml (limited to 'tests/auto/qml/qqmlecmascript') diff --git a/tests/auto/qml/qqmlecmascript/data/setPropertyOnNull.qml b/tests/auto/qml/qqmlecmascript/data/setPropertyOnNull.qml new file mode 100644 index 0000000000..a3288f47d7 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/setPropertyOnNull.qml @@ -0,0 +1,5 @@ +import QtQuick 2.2 + +QtObject { + Component.onCompleted: null.bug = 0 +} diff --git a/tests/auto/qml/qqmlecmascript/data/setPropertyOnUndefined.qml b/tests/auto/qml/qqmlecmascript/data/setPropertyOnUndefined.qml new file mode 100644 index 0000000000..6655c47e5f --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/setPropertyOnUndefined.qml @@ -0,0 +1,5 @@ +import QtQuick 2.2 + +QtObject { + Component.onCompleted: undefined.bug = 0 +} diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 609fb1d7a3..36ccbe0558 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -311,6 +311,7 @@ private slots: void qtbug_33754(); void qtbug_34493(); void singletonFromQMLToCpp(); + void setPropertyOnInvalid(); private: // static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); @@ -7361,6 +7362,27 @@ void tst_qqmlecmascript::singletonFromQMLToCpp() QCOMPARE(obj->property("myInheritedQmlObjectTest"), QVariant(true)); } +void tst_qqmlecmascript::setPropertyOnInvalid() +{ + { + QQmlComponent component(&engine, testFileUrl("setPropertyOnNull.qml")); + QString warning = component.url().toString() + ":4: TypeError: Type error"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QObject *object = component.create(); + QVERIFY(object); + delete object; + } + + { + QQmlComponent component(&engine, testFileUrl("setPropertyOnUndefined.qml")); + QString warning = component.url().toString() + ":4: TypeError: Type error"; + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QObject *object = component.create(); + QVERIFY(object); + delete object; + } +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3