aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Falsini <falsinsoft@gmail.com>2021-01-28 20:46:21 +0100
committerFabio Falsini <falsinsoft@gmail.com>2021-02-05 23:37:26 +0100
commitd0b1bef8b889ab852eaf906fdc9cd4219238872e (patch)
treec6dbb4530f50725827a7e2c13fbdfb6dce1d0e28
parent07a9cc199f101a11c83a9d75e5eb198134c75a8d (diff)
QQuickItemParticle give() method kill particle
Currently removing an item connected to a particle only invalidate the particle that will be reused for the next item set. This has the effect that the new item inserted appears in the same position as the old one just removed. This patch force killing the particle to assign next item to a new particle starting from initial position. Pick-to: 5.15 6.0 6.1 Change-Id: Ic937a6d7aea65368cceb1405bb81ef1502d988a5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/particles/qquickitemparticle.cpp1
-rw-r--r--tests/auto/particles/qquickitemparticle/data/takeGive.qml3
-rw-r--r--tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp4
3 files changed, 7 insertions, 1 deletions
diff --git a/src/particles/qquickitemparticle.cpp b/src/particles/qquickitemparticle.cpp
index ce254c212d..60d368a2a3 100644
--- a/src/particles/qquickitemparticle.cpp
+++ b/src/particles/qquickitemparticle.cpp
@@ -165,6 +165,7 @@ void QQuickItemParticle::give(QQuickItem *item)
if (data->delegate == item){
m_deletables << item;
data->delegate = nullptr;
+ m_system->groupData[groupId]->kill(data);
return;
}
}
diff --git a/tests/auto/particles/qquickitemparticle/data/takeGive.qml b/tests/auto/particles/qquickitemparticle/data/takeGive.qml
index e95ae738bd..926d83bfc1 100644
--- a/tests/auto/particles/qquickitemparticle/data/takeGive.qml
+++ b/tests/auto/particles/qquickitemparticle/data/takeGive.qml
@@ -65,9 +65,10 @@ Rectangle {
}
Emitter{
+ objectName: "emitter"
//0,0 position
size: 32
- emitRate: 1000
+ emitRate: 0
lifeSpan: Emitter.InfiniteLife
}
}
diff --git a/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp b/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
index 28ebbb3c05..538c429d1a 100644
--- a/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
+++ b/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
@@ -29,6 +29,7 @@
#include <QtTest/QtTest>
#include "../shared/particlestestsshared.h"
#include <private/qquickparticlesystem_p.h>
+#include <private/qquickparticleemitter_p.h>
#include <private/qquickimage_p.h>
#include <private/qabstractanimation_p.h>
@@ -114,11 +115,14 @@ void tst_qquickitemparticle::test_takeGive()
{
QQuickView* view = createView(testFileUrl("takeGive.qml"), 500);
QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
+ QQuickParticleEmitter* emitter = view->rootObject()->findChild<QQuickParticleEmitter*>("emitter");
QMetaObject::invokeMethod(view->rootObject(), "takeItems");
+ emitter->burst(100);
ensureAnimTime(1000, system->m_animation);
QVERIFY(system->property("acc").toInt() == 100);
QMetaObject::invokeMethod(view->rootObject(), "giveItems");
QTRY_VERIFY(system->property("acc").toInt() == 0);
+ QTRY_VERIFY(system->isEmpty() == true);
delete view;
}