Small dangling pointer tweak/fix to CCEventDispatcher

If cleaning a target node that has a listener in the 'to be added' listeners list then ensure that listener does not have a stale reference to the node. This is a minor tweak in addition to pull request 6160 (https://github.com/cocos2d/cocos2d-x/pull/6160).
This commit is contained in:
Darragh Coy 2014-04-08 08:46:09 -07:00
parent 6208943cb1
commit 0082900d10
1 changed files with 1 additions and 0 deletions

View File

@ -351,6 +351,7 @@ void EventDispatcher::removeEventListenersForTarget(Node* target, bool recursive
if (listener->getSceneGraphPriority() == target)
{
listener->setSceneGraphPriority(nullptr); // Ensure no dangling ptr to the target node.
listener->setRegistered(false);
listener->release();
iter = _toAddedListeners.erase(iter);