issue #2087: Fixing potential crash reported by Sam Gross. Thanks @Sam.

This commit is contained in:
James Chen 2013-09-20 10:23:58 +08:00
parent 4ba6924110
commit 213be32932
1 changed files with 15 additions and 0 deletions

View File

@ -175,6 +175,11 @@ void EventDispatcher::removeEventListener(EventListener* listener)
{
CC_SAFE_RETAIN(listener);
(*itemIter)->listener->_isRegistered = false;
if ((*itemIter)->node != nullptr)
{
(*itemIter)->node->dissociateEventListener(listener);
}
(*itemIter)->listener->release();
if (_inDispatch == 0)
{
@ -610,6 +615,11 @@ void EventDispatcher::removeListenersForEventType(const std::string& eventType)
for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter)
{
(*iter)->listener->_isRegistered = false;
if ((*iter)->node != nullptr)
{
(*iter)->node->dissociateEventListener((*iter)->listener);
}
(*iter)->listener->release();
if (_inDispatch)
{
@ -638,6 +648,11 @@ void EventDispatcher::removeAllListeners()
for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter)
{
(*iter)->listener->_isRegistered = false;
if ((*iter)->node != nullptr)
{
(*iter)->node->dissociateEventListener((*iter)->listener);
}
(*iter)->listener->release();
if (_inDispatch)
{