diff --git a/cocos2dx/cocoa/CCSet.cpp b/cocos2dx/cocoa/CCSet.cpp index 6ca9342b80..c957dedffb 100644 --- a/cocos2dx/cocoa/CCSet.cpp +++ b/cocos2dx/cocoa/CCSet.cpp @@ -109,15 +109,20 @@ void Set::removeObject(Object *pObject) void Set::removeAllObjects() { - for (SetIterator it = _set->begin(); it != _set->end(); ) + SetIterator it = _set->begin(); + SetIterator tmp; + + while (it != _set->end()) { if (!(*it)) { break; } - (*it)->release(); - _set->erase(it++); + tmp = it; + ++tmp; + _set->erase(it); + it = tmp; } }