When I move the mouse in the CCmenu,when ccmenu perform onExit function m_pSelectedItem may be NULL.
Could you upload a demo based on HelloCpp for reproducing this issue ?
I looked into CCMenu::ccTouchBegan function, found that only m_pSelectedItem != NULL, the m_eState will be assigned with kCCMenuStateTrackingTouch.
bool CCMenu::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
........
m_pSelectedItem = this->itemForTouch(touch);
if (m_pSelectedItem)
{
m_eState = kCCMenuStateTrackingTouch;
m_pSelectedItem->selected();
return true;
}
return false;
}
void CCMenu::onExit()
{
if (m_eState == kCCMenuStateTrackingTouch)
{// if entering here, m_pSelectedItem should be a non-Null value.
m_pSelectedItem->unselected();
m_eState = kCCMenuStateWaiting;
m_pSelectedItem = NULL;
}
CCLayer::onExit();
}
That’s right.But when touchMoved may be ItemForTouch return NULL.
斌 任 wrote:
When I move the mouse in the CCmenu,when ccmenu perform onExit function m_pSelectedItem may be NULL.
i think there’s a bug in CCMenu::removeChild()
if you’re going to remove a child which is touched from the CCMenu, pSelectedItem should be set NULL.
but CCMenu::removeChild doesn’t do it
you can see the solution:
http://hi.baidu.com/ligh0721/item/6bd9c5929930cbd87a7f01ee
Thank you, I will test your solution.
Issue #1547 was created for it. Thanks.