diff options
author | Chris Adams <christopher.adams@nokia.com> | 2011-12-29 10:32:52 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-29 05:52:22 +0100 |
commit | 8eec0518d628b59d4e6bfe3ee68ddabb1f83df08 (patch) | |
tree | 8ce268e05c6fe00ee199737b2a45561c37d9b6eb /tests/auto/declarative/qdeclarativeecmascript | |
parent | 78100927823edf9001d31c33162c634b5e4cf9d4 (diff) |
Handle exceptions inside QV8QObjectConnectionList::qt_metacall
Previously, exceptions were not handled in the connectionlist.
This could cause v8 to assert under certain circumstances.
Task-number: QTBUG-23375
Change-Id: Ie5f043b50bb6b02a77be464ca18ea8e3bbb0f501
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript')
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml | 24 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 15 |
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml b/tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml new file mode 100644 index 0000000000..acd512a2be --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/qobjectConnectionListExceptionHandling.qml @@ -0,0 +1,24 @@ +import QtQuick 2.0 + +Item { + id: root + property int first: 5 + property bool test: false + + Item { + id: exceptional + function exceptionalFunction() { + var obj = undefined; + var prop = undefined; + return obj[prop]; + } + } + + Component.onCompleted: { + root["firstChanged"].connect(exceptional.exceptionalFunction); + root["firstChanged"].connect(exceptional.exceptionalFunction); + root["firstChanged"].connect(exceptional.exceptionalFunction); + first = 6; + test = true; + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 0e3cfd8970..05e14cfc94 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -199,6 +199,7 @@ private slots: void qtbug_11606(); void qtbug_11600(); void qtbug_21864(); + void qobjectConnectionListExceptionHandling(); void nonscriptable(); void deleteLater(); void in(); @@ -5181,6 +5182,20 @@ void tst_qdeclarativeecmascript::qtbug_21864() delete o; } +void tst_qdeclarativeecmascript::qobjectConnectionListExceptionHandling() +{ + // QTBUG-23375 + QDeclarativeComponent component(&engine, testFileUrl("qobjectConnectionListExceptionHandling.qml")); + QString warning = component.url().toString() + QLatin1String(":13: TypeError: Cannot read property 'undefined' of undefined"); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test").toBool(), true); + delete o; +} + // Reading and writing non-scriptable properties should fail void tst_qdeclarativeecmascript::nonscriptable() { |