diff options
author | Alan Alpert <aalpert@blackberry.com> | 2015-01-26 11:50:11 -0800 |
---|---|---|
committer | Alan Alpert <aalpert@blackberry.com> | 2015-02-04 17:04:16 +0000 |
commit | 41db7b10e404f912ee7e7577a1fdf32996491162 (patch) | |
tree | a25321b1b8ebe2ff278e6b88a2c7c80981d8b04c /tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp | |
parent | 7be21bcde5afed368f191df6568dc16fac7b394a (diff) |
QQuickItemParticle: Only delete owned particles
A common pattern for ItemParticle (as shown in the particleview.qml
example) is to use it to manage movement of a model's delegates. In such
a case item management is handled by the user code (which bridges the
needs of the Model and the View) and deleting the items in ItemParticle
quickly leads to crashes.
This change maintains (and improves, due to handling resets) the
deletion of delegates created by the ItemParticles, as shown in
delegates.qml. This example was expanded with a click to reset feature
so as to more clearly see the impact of resets.
Task-number: QTBUG-37486
Change-Id: I9de935034c11a7dd2abdd60e7b3bd42867dede9c
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp')
-rw-r--r-- | tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp b/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp index c019f2e3bb..c825591972 100644 --- a/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp +++ b/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp @@ -48,6 +48,8 @@ public: private slots: void initTestCase(); void test_basic(); + void test_deletion(); + void test_noDeletion(); }; void tst_qquickitemparticle::initTestCase() @@ -87,6 +89,29 @@ void tst_qquickitemparticle::test_basic() delete view; } +void tst_qquickitemparticle::test_deletion() +{ + QQuickView* view = createView(testFileUrl("managed.qml"), 500); + QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system"); + ensureAnimTime(500, system->m_animation); + + QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 100, 10)); + //qDebug() << system->property("acc").toInt(); Seems to be around +15 due to the one frame delay in cleanup compared to creation + QVERIFY(extremelyFuzzyCompare(system->property("acc").toInt(), 100, 20)); + delete view; +} + +void tst_qquickitemparticle::test_noDeletion() +{ + QQuickView* view = createView(testFileUrl("unmanaged.qml"), 500); + QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system"); + ensureAnimTime(500, system->m_animation); + + QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 100, 10)); + QVERIFY(extremelyFuzzyCompare(system->property("acc").toInt(), 100, 10)); + delete view; +} + QTEST_MAIN(tst_qquickitemparticle); #include "tst_qquickitemparticle.moc" |