How can I remove a CCMenu? An entry of the CCMenu?

This is the source:

            CCMenuItemFont* contextEntry = CCMenuItemFont::create("Blablabla", this, menu_selector(HelloWorld::menuTestCallback) );
            CCMenu* contextMenu = CCMenu::create(contextEntry, NULL);
            this->addChild(contextMenu, 1);

I want remove this from the layer after pressing the Menu entry (contextEntry).
but a

contextEntry->release() 

crashed the program.

Any hints for me? Thanks.

You never want to do a release() unless you manually retain()’d it (which you don’t want to do here). Those things are for manual memory management. CCMenuItem, like many other CCNodes has autorelease built in, so you don’t have to worry about that! How cool is that? Try this if you just want to remove it like I think you do:

  contextEntry->removeFromParentAndCleanUp(true);

That’s the safe way to remove things with autorelease from their parents, and cocos2d-x will do release() on it’s own internally when it’s ready to release it from memory, behind the scenes.

Edit: I just saw your other thread where it looks like you try this and run into problems. I’m going over there.