From c6cd927ea5600391de4a5a8f023f0d383b4e2f33 Mon Sep 17 00:00:00 2001 From: Darragh Coy Date: Thu, 27 Mar 2014 15:37:16 -0700 Subject: [PATCH] When an event listener is removed from the scene and has a node associated with it, NULL out the node pointer so as not to leave any dangling pointers. --- cocos/2d/CCEventDispatcher.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/CCEventDispatcher.cpp b/cocos/2d/CCEventDispatcher.cpp index 20ff435504..9aa7126805 100644 --- a/cocos/2d/CCEventDispatcher.cpp +++ b/cocos/2d/CCEventDispatcher.cpp @@ -561,6 +561,7 @@ void EventDispatcher::removeEventListener(EventListener* listener) if (l->getSceneGraphPriority() != nullptr) { dissociateNodeAndEventListener(l->getSceneGraphPriority(), l); + l->setSceneGraphPriority(nullptr); // NULL out the node pointer so we don't have any dangling pointers to destroyed nodes. } if (_inDispatch == 0)