issue #2087: Bug fix in EventDispatcher: _isRegister fix.

This commit is contained in:
James Chen 2013-09-18 22:21:22 +08:00
parent 8fa969b39e
commit 3985574c30
1 changed files with 5 additions and 9 deletions

View File

@ -173,11 +173,10 @@ void EventDispatcher::removeEventListener(EventListener* listener)
{ {
if ((*itemIter)->listener == listener) if ((*itemIter)->listener == listener)
{ {
listener->retain(); (*itemIter)->listener->_isRegistered = false;
(*itemIter)->listener->release();
if (_inDispatch == 0) if (_inDispatch == 0)
{ {
(*itemIter)->listener->release();
delete (*itemIter); delete (*itemIter);
iter->second->erase(itemIter); iter->second->erase(itemIter);
} }
@ -207,11 +206,6 @@ void EventDispatcher::removeEventListener(EventListener* listener)
if (isFound) if (isFound)
break; break;
} }
if (isFound)
{
listener->release();
}
} }
void EventDispatcher::setPriority(EventListener* listener, int fixedPriority) void EventDispatcher::setPriority(EventListener* listener, int fixedPriority)
@ -610,6 +604,7 @@ void EventDispatcher::removeListenersForEventType(const std::string& eventType)
{ {
for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter) for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter)
{ {
(*iter)->listener->_isRegistered = false;
(*iter)->listener->release(); (*iter)->listener->release();
if (_inDispatch) if (_inDispatch)
{ {
@ -637,6 +632,7 @@ void EventDispatcher::removeAllListeners()
{ {
for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter) for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter)
{ {
(*iter)->listener->_isRegistered = false;
(*iter)->listener->release(); (*iter)->listener->release();
if (_inDispatch) if (_inDispatch)
{ {