CCAutoreleasePool does not check if an object is added twice.


The problem is very simple, Imagine the case when someone (by mistake) call “CCObject::autorelease” twice. This simply will access violation whenever that object is going to be deleted because that object is being deleted twice. I guess ObjectPool should be able to handle such cases or at least there should be an assertion. I can think of two possible solutions:

  1. check for duplicates whenever “void CCAutoreleasePool::addObject(CCObject* pObject)” is called
  2. add a flag is object is already managed by memory pool to members of all objects.


Traversing the autorelease array each time at CCAutoreleasePool::addObject seems a bit expensive. But we do already have a flag CCObject::m_bManaged.
I just fixed it in, related to issue #1492.

Thanks for your suggestion!


This final resolution is in #1494.
Adding an object twice into autorelease pool is allown. We tweak the ~CCObject() destructor a bit to avoid the bug.