Skip to content

Extract recursive mouse filter into NodeExtensions; fix popup event leak - #990

Closed
Billy-Lasso wants to merge 1 commit into
C7-Game:Developmentfrom
Billy-Lasso:billy/452-modal-input-refactor
Closed

Extract recursive mouse filter into NodeExtensions; fix popup event leak#990
Billy-Lasso wants to merge 1 commit into
C7-Game:Developmentfrom
Billy-Lasso:billy/452-modal-input-refactor

Conversation

@Billy-Lasso

Copy link
Copy Markdown

Closes #452.

Summary

1. Make modal mouse-filter blocking reusable (#452)
PopupOverlay had a private static SetMouseFilter that recursed through a subtree setting the Godot MouseFilter. This moves it to a public extension method, NodeExtensions.SetMouseFilterRecursive(this Node, Control.MouseFilterEnum), so any code can generically block/restore input to a subtree. PopupOverlay.Isolate()/Reconnect() now call it; the private helper is removed (along with a redundant control.MouseFilter assignment that the recursion already handled).

2. Fix a popup signal-handler leak (found while testing #452)
TileInfoPopup subscribes to PopupOverlay.Click to dismiss on an outside click (overlay.Click += Close) but never unsubscribes. Because the closed popup is only removed from the tree (not freed) and the delegate keeps it alive, the stale handler persists. Concretely: after opening any tile-info popup once, clicking outside a later modal (e.g. the Escape quit menu) would invoke the stale handler, which calls HideTileInfo()OnHidePopup(), closing the modal that should have stayed open. This unsubscribes in _ExitTree (guarded by IsInstanceValid for app teardown), so the tile-info dismiss behavior remains but can no longer affect other popups.

Testing

  • dotnet build C7/C7.sln: 0 errors.
  • dotnet test C7/C7.sln with CIV3_HOME set: 67 passed, 0 failed, 0 skipped.
  • Manual, in-game (Godot 4.4.1):
    • Modal popups (Escape quit menu, build-city, advisors) still block background input while open and restore it on close.
    • Tile-info popup still dismisses on an outside click.
    • Regression for the leak: open a tile-info popup, dismiss it, then open the Escape quit menu — clicking outside now correctly leaves the menu open.

…eak (#452)

Extract PopupOverlay's recursive SetMouseFilter into a public
NodeExtensions.SetMouseFilterRecursive so any subtree can have its
mouse filter set generically (modal input blocking).

Also fix a signal-handler leak: TileInfoPopup subscribes to the
overlay's Click event to dismiss on outside click, but never
unsubscribes, so a stale handler from a closed tile-info popup could
close later modals (e.g. the Escape quit menu) when clicking outside.
Unsubscribe in _ExitTree.
@Billy-Lasso

Copy link
Copy Markdown
Author

Closing - opened from the wrong GitHub account by mistake. Will reopen from the correct account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find a canonical way to block input to the whole screen and/or make blocking modals

2 participants