diff --git a/flixel/util/FlxSignal.hx b/flixel/util/FlxSignal.hx index 5558f9bac0..22de953eed 100644 --- a/flixel/util/FlxSignal.hx +++ b/flixel/util/FlxSignal.hx @@ -133,16 +133,21 @@ private class FlxBaseSignal implements IFlxSignal var handler = getHandler(listener); if (handler != null) { - if (processingListeners) - pendingRemove.push(handler); - else - { - handlers.remove(handler); - handler.destroy(); - } + removeHandler(handler); } } } + + inline function removeHandler(handler:FlxSignalHandler):Void + { + if (processingListeners) + pendingRemove.push(handler) + else + { + handlers.remove(handler); + handler.destroy(); + } + } public function has(listener:T):Bool { @@ -292,14 +297,14 @@ private class Macro handler.listener($a{exprs}); if (handler.dispatchOnce) - remove(handler.listener); + removeHandler(handler); } processingListeners = false; for (handler in pendingRemove) { - remove(handler.listener); + removeHandler(handler); } if (pendingRemove.length > 0) pendingRemove = [];