From b8889b830b49e4baec3dfdc530e1e95981250b11 Mon Sep 17 00:00:00 2001 From: T1mL3arn Date: Mon, 8 Jan 2024 20:55:34 +1000 Subject: [PATCH] Remove handler directly since we already work with it. This fixes one-time listeners for HL target ( see HaxeFoundation/hashlink#578 ) --- flixel/util/FlxSignal.hx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) 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 = [];