Only use emitCap when we run into infinite particles
authorAlan Alpert <aalpert@blackberry.com>
Mon, 29 Apr 2013 20:21:10 +0000 (13:21 -0700)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sat, 4 May 2013 04:26:22 +0000 (06:26 +0200)
emitCap is intended to prevent issues with multiple emission of infinite
life particles, but it can currently prevent emission of any particles
when particleCount() changes after a reset. Tracking particleCount() on
changes would be inefficient and be more work to integrate with the
correct behavior of infinite particles, so this patch delays the impact
of emitCap until an infinite particle is discovered.

This will lead to a subtle behavior difference of limiting infinite
particle counts based on the count at the first emission, not the first
reset, which could be construed as a bug fix in some situations. This
seems reasonable as a futher subtle behavior change will be needed in
the future to properly support varying counts of infinite particles.

Task-number: QTBUG-30915
Change-Id: I4172aee1d03f00cc63ce7c9d12ace052bc41436d
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
src/particles/qquickparticleemitter.cpp

index b4e3a82..ec8b53e 100644 (file)
@@ -357,7 +357,7 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
             m_last_timestamp = timeStamp/1000.;
         m_last_emission = m_last_timestamp;
         m_reset_last = false;
-        m_emitCap = particleCount();
+        m_emitCap = -1;
     }
 
     if (m_pulseLeft){
@@ -424,6 +424,8 @@ void QQuickParticleEmitter::emitWindow(int timeStamp)
 
             if (datum->lifeSpan >= m_system->maxLife){
                 datum->lifeSpan = m_system->maxLife;
+                if (m_emitCap == -1)
+                    m_emitCap = particleCount();
                 m_emitCap--;//emitCap keeps us from reemitting 'infinite' particles after their life. Unless you reset the emitter.
             }