issue #2087: [EventDispatcher] Fixing crash on Win32.

This commit is contained in:
James Chen 2013-09-19 10:19:02 +08:00
parent f78634617c
commit 7797fad5a5
1 changed files with 9 additions and 4 deletions

View File

@ -166,13 +166,14 @@ void EventDispatcher::removeEventListener(EventListener* listener)
return;
bool isFound = false;
for (auto iter = _listeners.begin(); iter != _listeners.end();)
{
for (auto itemIter = iter->second->begin(); itemIter != iter->second->end(); ++itemIter)
{
if ((*itemIter)->listener == listener)
{
{
CC_SAFE_RETAIN(listener);
(*itemIter)->listener->_isRegistered = false;
(*itemIter)->listener->release();
if (_inDispatch == 0)
@ -192,11 +193,10 @@ void EventDispatcher::removeEventListener(EventListener* listener)
if (iter->second->empty())
{
_priorityDirtyFlagMap.erase(listener->_type);
auto list = iter->second;
iter = _listeners.erase(iter);
CC_SAFE_DELETE(list);
_priorityDirtyFlagMap.erase(listener->_type);
}
else
{
@ -206,6 +206,11 @@ void EventDispatcher::removeEventListener(EventListener* listener)
if (isFound)
break;
}
if (isFound)
{
CC_SAFE_RELEASE(listener);
}
}
void EventDispatcher::setPriority(EventListener* listener, int fixedPriority)