Review feedback: fix memory leak discovered.

Always safe release the listener we retain - shift where release happens to the end of the block. Reproduced the leak using the Xcode Leaks instrument in the RemoveListenerAfterAddingTest and verified fixed after apply this change.
This commit is contained in:
Darragh Coy 2014-03-27 11:28:27 -07:00
parent 0ee1095e37
commit 07646f1c82
1 changed files with 1 additions and 1 deletions

View File

@ -576,7 +576,6 @@ void EventDispatcher::removeEventListener(EventListener* listener)
if (_inDispatch == 0)
{
listeners->erase(iter);
CC_SAFE_RELEASE(l);
}
else
{
@ -587,6 +586,7 @@ void EventDispatcher::removeEventListener(EventListener* listener)
}
isFound = true;
CC_SAFE_RELEASE(l);
break;
}
}