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 <qt_sanity_bot@ovi.com>
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
This commit is contained in:
Alan Alpert 2011-07-25 15:12:17 +10:00 committed by Qt by Nokia
parent d197b2d2cd
commit 02bf8f421d
2 changed files with 7 additions and 8 deletions

View 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){

View 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);