🚨 Stop the range selection helper from leaking

Abandoning a selection after the first click leaked the helper and
kept it registered for tile clicks. The helper now tracks the active
instance, copies coordinates instead of holding tile references that
can be evicted, and the listener dispatch tolerates removal during
iteration.
This commit is contained in:
2026-11-15 22:06:51 +01:00
parent a1a40b6f61
commit 997aa4991a
2 changed files with 36 additions and 38 deletions
+3 -3
View File
@@ -729,7 +729,7 @@ var
tileX, tileY, newX, newY: Word;
targetBlocks: TBlockInfoList;
targetTile: TWorldItem;
selectionListener: TSelectionListener;
listenerIndex: Integer;
begin
Logger.EnterMethod([lcClient, lcDebug], 'MouseUp');
if Button <> mbLeft then
@@ -757,9 +757,9 @@ begin
mnuGrabTileIDClick(nil);
end;
for selectionListener in FSelectionListeners do
for listenerIndex := FSelectionListeners.Count - 1 downto 0 do
begin
selectionListener(CurrentTile);
FSelectionListeners[listenerIndex](CurrentTile);
end;
end;