diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-07-18 10:16:12 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-20 05:35:13 +0200 |
commit | fa3dcc0efb2696612bf9db54a7ed4e26a2cf4765 (patch) | |
tree | 1a571292334edd0ea10fda559b8c84862a51b58b /tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | |
parent | 9018c236c73884ea706ac1d04a306467454e6243 (diff) |
Update var property to null on object deletion
When a var property contains a pointer to a QObject-derived instance,
ensure that object deletion causes the property to be updated.
Task-number: QTBUG-26542
Change-Id: I67a59ffd7f09063328d45dc84889add55a5428e4
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp')
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 2c9593bd01..316d7e28a7 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -179,6 +179,9 @@ private slots: void literals_data(); void literals(); + void objectDeletionNotify_data(); + void objectDeletionNotify(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -2987,6 +2990,37 @@ void tst_qqmllanguage::literals() delete object; } +void tst_qqmllanguage::objectDeletionNotify_data() +{ + QTest::addColumn<QString>("file"); + + QTest::newRow("property QtObject") << "objectDeletionNotify.1.qml"; + QTest::newRow("property variant") << "objectDeletionNotify.2.qml"; + QTest::newRow("property var") << "objectDeletionNotify.3.qml"; + QTest::newRow("property var guard removed") << "objectDeletionNotify.4.qml"; +} + +void tst_qqmllanguage::objectDeletionNotify() +{ + QFETCH(QString, file); + + QQmlComponent component(&engine, testFile(file)); + + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(object->property("success").toBool(), true); + + QMetaObject::invokeMethod(object, "destroyObject"); + + // Process the deletion event + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + + QCOMPARE(object->property("success").toBool(), true); + + delete object; +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" |