title: Removing a CCNode from std::list causes error in XCode
body: <p>I'm having trouble deleting items from a <code>std::list</code> containing <code>CCNode</code> object. XCode gives me the following error when trying to <code>erase()</code> an element: </p>
  
  <p><code>error: address doesn't contain a section that points to a section in a object file</code>.</p>
  
  <p>Or this error:</p>
  
  <p><code>EXC_BAD_ACCESS code=2</code> at an assembly file.</p>
  
  <p>And sometimes it crashes at:</p>
  
  <p><code>ccGLBindTexture2D( m_pobTexture-&gt;getName() );</code> giving me an EXC_BAD_ACCESS.</p>
  
  <p>Each time I run the application I get one of those errors.</p>
  
  <p>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.</p>
  
  <p>I wrote a test case to reproduce the problem. Here it is: </p>
  
  <pre><code>testList = *new list&lt;TestObject&gt;;
  testList.push_back(*new TestObject());
  addChild(&amp;testList.back());
  testList.back().spawn();
  testList.back().remove();
  
  std::list&lt;TestObject&gt;::iterator test = testList.begin();
  while (test != testList.end())
  {
      if(test-&gt;isRemoved){
          testList.erase(test++);
      }
  }
  </code></pre>
  
  <p>The TestObject class is simply a CCNode with the following <code>remove()</code> and <code>spawn()</code> methods added: </p>
  
  <pre><code>TestObject::TestObject(){
      sprite = *CCSprite::createWithTexture(MainScene::hostileship_tex);
  }
  
  void TestObject::spawn(){
      CCSize size = sprite.getTexture()-&gt;getContentSize();
      this-&gt;setContentSize(size);
      this-&gt;addChild(&amp;sprite);
  }
  
  void TestObject::remove(){
      GameLayer::getInstance().removeChild(this, true);
  }
  </code></pre>
  
  <p>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.</p>