CCCallFunc doesn't work under release mode?

CCCallFunc doesn't work under release mode?
0.0 0



I’m trying to create an explosion effect.
I have an animation, and I play the animation with a sprite. once the animation is finished, I remove the sprite from the scene:

here is how I create the action:

cocos2d::CCCallFunc * callFunc = cocos2d::CCCallFunc::create( effectSprite, callfunc_selector( GameScene::explosionAnimationFinished ) );
cocos2d::CCLog(“ex create: x", effectSprite);
effectSprite->runAction(cocos2d::CCSequence::create( theAnim, callFunc, NULL ) );

this is the callback function:

void GameScene::explosionAnimationFinished(cocos2d::CCObject * p_Sender)
cocos2d::CCNode *sprite = (cocos2d::CCNode*)p_Sender;
cocos2d::CCLog("ex read: x”, p_Sender);

this code works well under debug mode, but crash in release mode due to BAD_ACCESS

I debugged this a little bit, it turned out that the p_Sender of the callback function is an invalide pointer in the release mode.

it seems that when calling the call back function, CCCallFunc doesn’t pass in the sender:

void CCCallFunc::execute() {
if (m_pCallFunc) {
(m_pSelectorTarget->*m_pCallFunc)(); //sender is not passed in here


I changed (m_pSelectorTarget->*m_pCallFunc)(); to (m_pSelectorTarget->*m_pCallFunc)((CCNode*)m_pSelectorTarget);
and it worked.

is this a bug?


I beleive CCCallFunc delegate takes no arguments. You should use CCCallFuncN or CCCallFuncO in order to pass the sender back.