mirror of https://github.com/axmolengine/axmol.git
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:
parent
0ee1095e37
commit
07646f1c82
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue