mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3705 from dumganhar/iss2087-new-event-dispatcher
issue #2087: [EventDispatcher] Fixing crash on Win32.
This commit is contained in:
commit
4b3b69bb6b
|
@ -173,6 +173,7 @@ void EventDispatcher::removeEventListener(EventListener* listener)
|
||||||
{
|
{
|
||||||
if ((*itemIter)->listener == listener)
|
if ((*itemIter)->listener == listener)
|
||||||
{
|
{
|
||||||
|
CC_SAFE_RETAIN(listener);
|
||||||
(*itemIter)->listener->_isRegistered = false;
|
(*itemIter)->listener->_isRegistered = false;
|
||||||
(*itemIter)->listener->release();
|
(*itemIter)->listener->release();
|
||||||
if (_inDispatch == 0)
|
if (_inDispatch == 0)
|
||||||
|
@ -192,11 +193,10 @@ void EventDispatcher::removeEventListener(EventListener* listener)
|
||||||
|
|
||||||
if (iter->second->empty())
|
if (iter->second->empty())
|
||||||
{
|
{
|
||||||
|
_priorityDirtyFlagMap.erase(listener->_type);
|
||||||
auto list = iter->second;
|
auto list = iter->second;
|
||||||
iter = _listeners.erase(iter);
|
iter = _listeners.erase(iter);
|
||||||
CC_SAFE_DELETE(list);
|
CC_SAFE_DELETE(list);
|
||||||
|
|
||||||
_priorityDirtyFlagMap.erase(listener->_type);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -206,6 +206,11 @@ void EventDispatcher::removeEventListener(EventListener* listener)
|
||||||
if (isFound)
|
if (isFound)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isFound)
|
||||||
|
{
|
||||||
|
CC_SAFE_RELEASE(listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::setPriority(EventListener* listener, int fixedPriority)
|
void EventDispatcher::setPriority(EventListener* listener, int fixedPriority)
|
||||||
|
|
Loading…
Reference in New Issue