Manage m_activeCount centrally
authorAlan Alpert <alan.alpert@nokia.com>
Mon, 25 Jul 2011 05:12:17 +0000 (15:12 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 28 Jul 2011 06:39:33 +0000 (08:39 +0200)
Fixes issue where it wasn't being managed right and kept going negative.
This commit also adds setVisible in a few places missed by the last
change.

Task-number: QTBUG-20437
Change-Id: I4efaab7b34784dfbc42dd1acd0a5be3b38a8605a
Reviewed-on: http://codereview.qt.nokia.com/2074
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
src/declarative/particles/qsgitemparticle.cpp
src/declarative/particles/qsgmodelparticle.cpp

index 878e04d..19d921a 100644 (file)
@@ -121,10 +121,8 @@ void QSGItemParticle::tick()
         if (m_stasis.contains(d->delegate))
             qWarning() << "Current model particles prefers overwrite:false";
         //remove old item from the particle that is dying to make room for this one
-        if (d->delegate){
+        if (d->delegate)
             m_deletables << d->delegate;
-            m_activeCount--;
-        }
         d->delegate = 0;
         if (!m_pendingItems.isEmpty()){
             d->delegate = m_pendingItems.front();
@@ -143,6 +141,7 @@ void QSGItemParticle::tick()
             d->delegate->setParentItem(this);
             if (m_fade)
                 d->delegate->setOpacity(0.);
+            d->delegate->setVisible(false);//Will be set to true when we prepare the next frame
             m_activeCount++;
         }
     }
@@ -202,7 +201,6 @@ void QSGItemParticle::prepareNextFrame()
             if (t >= 1.0){//Usually happens from load
                 m_deletables << item;
                 data->delegate = 0;
-                m_activeCount--;
             }else{//Fade
                 data->delegate->setVisible(true);
                 if (m_fade){
index 08646e3..19815aa 100644 (file)
@@ -171,7 +171,6 @@ void QSGModelParticle::initialize(int gIdx, int pIdx)
     if (m_available.isEmpty())
         return;
     m_requests << m_system->m_groupData[gIdx]->data[pIdx];
-    m_activeCount++;
 }
 
 void QSGModelParticle::processPending()
@@ -181,6 +180,7 @@ void QSGModelParticle::processPending()
         if (m_fade)
             item->setOpacity(0.);
         m_model->release(item);
+        m_activeCount--;
     }
     m_deletables.clear();
 
@@ -193,7 +193,6 @@ void QSGModelParticle::processPending()
             m_available << datum->modelIndex;
             datum->modelIndex = -1;
             datum->delegate = 0;
-            m_activeCount--;
         }
 
         if (!m_available.isEmpty()){
@@ -206,7 +205,10 @@ void QSGModelParticle::processPending()
                 mpa->attach();
             }
             datum->delegate->setParentItem(this);
-            datum->delegate->setOpacity(0.0);
+            if (m_fade)
+                datum->delegate->setOpacity(0.0);
+            datum->delegate->setVisible(false);//Will be set to true when we prepare the next frame
+            m_activeCount++;
         }
     }
     m_requests.clear();
@@ -271,7 +273,6 @@ void QSGModelParticle::prepareNextFrame()
                 m_deletables << data->delegate;
                 data->modelIndex = -1;
                 data->delegate = 0;
-                m_activeCount--;
                 continue;
             }else{//Fade
                 data->delegate->setVisible(true);