I’m having trouble deleting items from a `std::list` containing `CCNode` object. XCode gives me the following error when trying to `erase()` an element:
error: address doesn't contain a section that points to a section in a object file.
Or this error:
EXC_BAD_ACCESS code=2 at an assembly file.
And sometimes it crashes at:
ccGLBindTexture2D( m_pobTexture->getName() ); giving me an EXC_BAD_ACCESS.
Each time I run the application I get one of those errors.
The remove() method correctly removes the CCNode from the CCLayer, it disappears and the node count goes down by one. The problem is that the TestObject still remains in the testList list, eating up memory, cpu, and messing up the game.
I wrote a test case to reproduce the problem. Here it is:
testList = *new list;
std::list::iterator test = testList.begin();
while (test != testList.end())
The TestObject class is simply a CCNode with the following
spawn() methods added:
sprite = *CCSprite::createWithTexture(MainScene::hostileship_tex);
CCSize size = sprite.getTexture()->getContentSize();
The stacktrace XCode gives me just lists a couple of internal update and render functions of cocos2dx, giving me no idea whats causing the crash.