fixed #1494: Change the value of CCObject::m_uAutoreleaseCount in CCAutoreleasePool class.

This commit is contained in:
James Chen 2012-10-08 14:05:03 +08:00
parent 54b4c690d1
commit 6d29e63294
2 changed files with 6 additions and 8 deletions

View File

@ -44,13 +44,16 @@ void CCAutoreleasePool::addObject(CCObject* pObject)
m_pManagedObjectArray->addObject(pObject);
CCAssert(pObject->m_uReference > 1, "reference count should be greater than 1");
++(pObject->m_uAutoReleaseCount);
pObject->release(); // no ref count, in this case autorelease pool added.
}
void CCAutoreleasePool::removeObject(CCObject* pObject)
{
m_pManagedObjectArray->removeObject(pObject, false);
for (int i = 0; i < pObject->m_uAutoReleaseCount; ++i)
{
m_pManagedObjectArray->removeObject(pObject, false);
}
}
void CCAutoreleasePool::clear()

View File

@ -53,10 +53,7 @@ CCObject::~CCObject(void)
// from pool manager
if (m_uAutoReleaseCount > 0)
{
for (int i = 0; i < m_uAutoReleaseCount; ++i)
{
CCPoolManager::sharedPoolManager()->removeObject(this);
}
CCPoolManager::sharedPoolManager()->removeObject(this);
}
// if the object is referenced by Lua engine, remove it
@ -100,8 +97,6 @@ void CCObject::retain(void)
CCObject* CCObject::autorelease(void)
{
CCPoolManager::sharedPoolManager()->addObject(this);
++m_uAutoReleaseCount;
return this;
}