From 02bf8f421d32ef7449b0fe2fe1ad62fea33bcc61 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 25 Jul 2011 15:12:17 +1000 Subject: [PATCH] Manage m_activeCount centrally 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 Reviewed-by: Alan Alpert --- src/declarative/particles/qsgitemparticle.cpp | 6 ++---- src/declarative/particles/qsgmodelparticle.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/declarative/particles/qsgitemparticle.cpp b/src/declarative/particles/qsgitemparticle.cpp index 878e04d..19d921a 100644 --- a/src/declarative/particles/qsgitemparticle.cpp +++ b/src/declarative/particles/qsgitemparticle.cpp @@ -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){ diff --git a/src/declarative/particles/qsgmodelparticle.cpp b/src/declarative/particles/qsgmodelparticle.cpp index 08646e3..19815aa 100644 --- a/src/declarative/particles/qsgmodelparticle.cpp +++ b/src/declarative/particles/qsgmodelparticle.cpp @@ -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); -- 2.7.4