aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2024-03-14 09:38:00 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-15 08:54:40 +0000
commitc34daa62e6efad6566fab478c3f937030f1828fb (patch)
tree13373212547cfe9e22d4dc480024ca7753ded149
parent0e4d4d4a4f54592ee698dc73896e60bfc672bcc0 (diff)
Fix deadlock in long-running particle system
2^30 was used as a "big number" sentinel and assumed to always be higher than the particle system's age. But a particle system running for a bit over 12 days will hit this limit. The result was that such particle systems would never exit the loop in recycle() and deadlock. Instead we add the check for an empty heap to the loop condition itself. Pick-to: 6.5 6.2 5.15 Fixes: QTBUG-123111 Change-Id: I6bf9c5a27271e74f56728c0ad7bdabdd87e028b2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 9c54252914634a6756b39261b027b48b96c6ea7b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit fd53ed433a18a369984d87614921bbeed92997b1)
-rw-r--r--src/particles/qquickparticlesystem.cpp5
-rw-r--r--src/particles/qquickparticlesystem_p.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/particles/qquickparticlesystem.cpp b/src/particles/qquickparticlesystem.cpp
index 655cd4a78e..c75d1127a1 100644
--- a/src/particles/qquickparticlesystem.cpp
+++ b/src/particles/qquickparticlesystem.cpp
@@ -204,8 +204,7 @@ void QQuickParticleDataHeap::insertTimed(QQuickParticleData* data, int time)
int QQuickParticleDataHeap::top()
{
- if (m_end == 0)
- return 1 << 30;
+ Q_ASSERT(!isEmpty());
return m_data[0].time;
}
@@ -355,7 +354,7 @@ bool QQuickParticleGroupData::recycle()
{
m_latestAliveParticles.clear();
- while (dataHeap.top() <= m_system->timeInt) {
+ while (!dataHeap.isEmpty() && dataHeap.top() <= m_system->timeInt) {
for (QQuickParticleData *datum : dataHeap.pop()) {
if (!datum->stillAlive(m_system)) {
freeList.free(datum->index);
diff --git a/src/particles/qquickparticlesystem_p.h b/src/particles/qquickparticlesystem_p.h
index 90b9434fa9..e7fc6de0e2 100644
--- a/src/particles/qquickparticlesystem_p.h
+++ b/src/particles/qquickparticlesystem_p.h
@@ -83,6 +83,8 @@ public:
int top();
+ bool isEmpty() const { return m_end == 0; }
+
QSet<QQuickParticleData*> pop();
void clear();