diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-07-29 13:53:35 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-29 09:39:41 +0200 |
commit | 0e68a621135102cd441e4bce725628a07d51f353 (patch) | |
tree | 93919d1c1f6a4311d33b0b41f86c2bdfdfb5cd29 /tests/auto/declarative/qdeclarativeecmascript | |
parent | 8fed8bf724b0df6e7b63080a98955f2e295f11c6 (diff) |
Mark objects from Component.createObject() as destructible
Change-Id: I00a1a2b5cca80c3e2ea097690cadf21581e1356d
Task-number: QTBUG-20626
Reviewed-on: http://codereview.qt.nokia.com/2367
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeecmascript')
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml | 21 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 22 |
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml new file mode 100644 index 0000000000..70c281691b --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/dynamicDeletion.2.qml @@ -0,0 +1,21 @@ +import QtQuick 1.0 + +QtObject { + id: root + + property QtObject objectProperty + + property Component c: Component { + id: componentObject + QtObject { + } + } + + function create() { + objectProperty = c.createObject(root); + } + + function destroy() { + objectProperty.destroy(); + } +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index bc33932442..b1bc5bda2b 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1074,6 +1074,7 @@ void tst_qdeclarativeecmascript::dynamicCreation() */ void tst_qdeclarativeecmascript::dynamicDestruction() { + { QDeclarativeComponent component(&engine, TEST_FILE("dynamicDeletion.qml")); QDeclarativeGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create()); QVERIFY(object != 0); @@ -1102,6 +1103,27 @@ void tst_qdeclarativeecmascript::dynamicDestruction() QTest::qWait(0); QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion); QVERIFY(!object); + } + + { + QDeclarativeComponent component(&engine, TEST_FILE("dynamicDeletion.2.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); + + QMetaObject::invokeMethod(o, "create"); + + QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) != 0); + + QMetaObject::invokeMethod(o, "destroy"); + + QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion); + + QVERIFY(qvariant_cast<QObject*>(o->property("objectProperty")) == 0); + + delete o; + } } /* |