I've run into an... interesting problem. I've found that my program is crashing on a standard get statement. For context, I'm overriding the onEnter
function (from Cocos2dx framework) to swap an image after modifications in a further scene.
My modification looks as follows:
icons is map< ClassA, CCSprite* >
current
is of ClassA
void onEnter(){
<parent class>::onEnter();
CCSprite* sprite = icons[current];
if (sprite){
CCNode* parent = sprite->getParent(); //Crashes Here
if (parent){...}
}
}
From Cocos2d-x:
CCNode* getParent(){
return m_pParent;
}
Note: I don't have issues with calling this function anywhere else but here.
Also:
Yes, icons exists
Yes, current exists
Yes, sprite exists
current is not a pointer
If it helps I'm using QNX Momentics IDE.
EDIT:: Here's an image
It looks like it wasn't a valid CCSprite. In between the declaration and calling of onEnter the release pool that cocos2dx uses marked it for delete. It seems in some cases during the constructor, the CCSprite wasn't added to a parent and it wasn't marked for retention. Thus, it was deleted but some garbage remained. Thanks Cyber.