Crashes in CCMenuItem* CCMenu::itemForTouch(CCTouch *touch)

Crashes in CCMenuItem* CCMenu::itemForTouch(CCTouch *touch)
0.0 0


Hello, everybody.

When I start up my first demo in android(Windows) by following Tutorials.
The program Crashes in the function CCMenu::itemForTouch.(My NDK is 7rd, and used cocos2d-1.0.1-x-0.11.0, run in android 2.2 emulator).

When I make a little change to CCMenu::itemForTouch, the crash problem disappeared.
Is it a bug of cocos OR g++ ?

Hope for reply. Thanks.

Code is pasted below.

CCMenuItem* CCMenu::itemForTouch(CCTouch *touch)
CCPoint touchLocation = touch~~>locationInView);
touchLocation = CCDirector::sharedDirector~~>convertToGL;
if > 0)
CCObject* pObject = NULL;
//CCNode* pChild = dynamic_cast<CCNode*>;
↑↑↑↑ ★★★ if I change dynamic_cast to the code below. The crash clear. It seems dynamic_cast got a wrong address.
CCNode* pChild = ;
if && pChild)>getIsEnabled)<— ★★★ it crashes here.
CCPoint local = pChild
CCRect r = ((CCMenuItem*)pChild)>rect;
r.origin = CCPointZero;
if )
return pChild;
return NULL;


Just made a test. Paste up the test result.(use g++ 4.4.0.)
I create a CCMenuItemImage named pTestItem, and then do some cast as belows.

>> CCObject pTestObj1 = pTestItem;
>> CCObject
pTestObj2 = dynamic_cast<CCObject*>(pTestItem);

>> CCNode pTestNode1 = pTestItem;
>> CCNode
pTestNode2 = dynamic_cast<CCNode*>(pTestItem);

>> CCNode pTestNode3 = pTestObj1;
>> CCNode
pTestNode4 = dynamic_cast<CCNode*>(pTestObj1);

The address of each parment is below.
It seems pTestNode4 is strangely, got a wrong address.





It is a matter of g++, may be you can refer
So we build cocos2d-x as a static lib, and it can resolve the problem.


Thank you for reply, Minggo Zhang.

I will try the static-lib way.