Skip to content

Commit

Permalink
Remove handler directly since we already work with it. This fixes one…
Browse files Browse the repository at this point in the history
…-time listeners for HL target ( see HaxeFoundation/hashlink#578 )
  • Loading branch information
T1mL3arn committed Jan 8, 2024
1 parent 13e63e0 commit b8889b8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions flixel/util/FlxSignal.hx
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,21 @@ private class FlxBaseSignal<T> implements IFlxSignal<T>
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<T>):Void
{
if (processingListeners)
pendingRemove.push(handler)
else
{
handlers.remove(handler);
handler.destroy();
}
}

public function has(listener:T):Bool
{
Expand Down Expand Up @@ -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 = [];
Expand Down

0 comments on commit b8889b8

Please sign in to comment.