Merge pull request #6157 from dbaack/remove_event_listener_fix

closed #4700: Removing and re-adding an event listener will trigger an assert.
This commit is contained in:
James Chen 2014-04-07 16:14:48 +08:00
commit 7142dcfce3
1 changed files with 2 additions and 0 deletions

View File

@ -637,6 +637,7 @@ void EventDispatcher::removeEventListener(EventListener* listener)
{
if (*iter == listener)
{
listener->setRegistered(false);
listener->release();
_toAddedListeners.erase(iter);
break;
@ -1252,6 +1253,7 @@ void EventDispatcher::removeEventListenersForListenerID(const EventListener::Lis
{
if ((*iter)->getListenerID() == listenerID)
{
(*iter)->setRegistered(false);
(*iter)->release();
iter = _toAddedListeners.erase(iter);
}