bugfix related to AutoreleasePool's PoolManager

* duplicated AutoreleasePool added to PoolManager in
  PoolManager::getInstance()
* redundant pop_back() in PoolManager::~PoolManager()
This commit is contained in:
Kezhu Wang 2014-06-03 18:57:52 +08:00
parent dbca937835
commit 1eb991df59
1 changed files with 3 additions and 12 deletions

View File

@ -111,8 +111,7 @@ PoolManager* PoolManager::getInstance()
{ {
s_singleInstance = new PoolManager(); s_singleInstance = new PoolManager();
// Add the first auto release pool // Add the first auto release pool
s_singleInstance->_curReleasePool = new AutoreleasePool("cocos2d autorelease pool"); new AutoreleasePool("cocos2d autorelease pool");
s_singleInstance->_releasePoolStack.push_back(s_singleInstance->_curReleasePool);
} }
return s_singleInstance; return s_singleInstance;
} }
@ -134,7 +133,6 @@ PoolManager::~PoolManager()
while (!_releasePoolStack.empty()) while (!_releasePoolStack.empty())
{ {
AutoreleasePool* pool = _releasePoolStack.back(); AutoreleasePool* pool = _releasePoolStack.back();
_releasePoolStack.pop_back();
delete pool; delete pool;
} }
@ -164,16 +162,9 @@ void PoolManager::push(AutoreleasePool *pool)
void PoolManager::pop() void PoolManager::pop()
{ {
// Can not pop the pool that created by engine CC_ASSERT(!_releasePoolStack.empty());
CC_ASSERT(_releasePoolStack.size() >= 1);
_releasePoolStack.pop_back(); _releasePoolStack.pop_back();
_curReleasePool = _releasePoolStack.empty() ? nullptr : _releasePoolStack.back();
// Should update _curReleasePool if a temple pool is released
if (_releasePoolStack.size() > 1)
{
_curReleasePool = _releasePoolStack.back();
}
} }
NS_CC_END NS_CC_END