From 49e086e5267a5bb512163bb3c6ba568002669e9d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 23 Oct 2009 18:29:05 +1000 Subject: Clear exceptions after a binding evaluation --- src/declarative/qml/qmlexpression.cpp | 1 + .../qmlecmascript/data/exceptionClearsOnReeval.qml | 6 ++++++ .../qmlecmascript/tst_qmlecmascript.cpp | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 7f01f0e..3f531a3 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -323,6 +323,7 @@ QVariant QmlExpressionPrivate::evalQtScript(QObject *secondaryScope, bool *isUnd if (scriptEngine->hasUncaughtException()) { printException(scriptEngine); + scriptEngine->clearExceptions(); return QVariant(); } diff --git a/tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml b/tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml new file mode 100644 index 0000000..a2f0d1a --- /dev/null +++ b/tests/auto/declarative/qmlecmascript/data/exceptionClearsOnReeval.qml @@ -0,0 +1,6 @@ +import Qt.test 1.0 + +MyQmlObject { + property bool test: objectProperty.objectProperty.trueProperty +} + diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index a7a2ef6..a0e65c5 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -65,6 +65,7 @@ private slots: void scriptErrors(); void signalTriggeredBindings(); void listProperties(); + void exceptionClearsOnReeval(); private: QmlEngine engine; @@ -818,6 +819,27 @@ void tst_qmlecmascript::listProperties() QCOMPARE(object->property("test8").toBool(), true); } +void tst_qmlecmascript::exceptionClearsOnReeval() +{ + QmlComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml")); + QString url = component.url().toString(); + + QString warning = url + ":4: TypeError: Result of expression 'objectProperty.objectProperty' [undefined] is not an object."; + + QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); + MyQmlObject *object = qobject_cast(component.create()); + QVERIFY(object != 0); + + QCOMPARE(object->property("test").toBool(), false); + + MyQmlObject object2; + MyQmlObject object3; + object2.setObjectProperty(&object3); + object->setObjectProperty(&object2); + + QCOMPARE(object->property("test").toBool(), true); +} + QTEST_MAIN(tst_qmlecmascript) #include "tst_qmlecmascript.moc" -- cgit v0.12