Skip to content

Fix Project-Wide Signal Leaks in UI Components#269

Merged
niyazmft merged 3 commits into
mainfrom
fix/signal-leak-epidemic-12029236788707118407
Jun 9, 2026
Merged

Fix Project-Wide Signal Leaks in UI Components#269
niyazmft merged 3 commits into
mainfrom
fix/signal-leak-epidemic-12029236788707118407

Conversation

@niyazmft

@niyazmft niyazmft commented Jun 9, 2026

Copy link
Copy Markdown
Owner

This PR addresses a project-wide signal leak issue where UI nodes were connecting to long-lived signals (Autoloads, SceneTree) in _ready() but failing to disconnect in _exit_tree().

Key changes:

  1. Bound Callable Management: In settings_panel.gd, bound callables are now stored in a _bound_callables dictionary. This is necessary because Godot 4 creates new Callable instances on every .bind() call, making it impossible to disconnect without a reference to the specific instance used during connection.
  2. Modal Inheritance: DefeatModal and VictoryModal were updated to extend the base _Modal class. This ensures consistent behavior and that parent signal cleanup (like the close button) is executed via super._exit_tree().
  3. Timer Safety: Short-lived SceneTreeTimer objects used for UI feedback (like conflict warnings) are now stored in member variables and disconnected in _exit_tree() to prevent callbacks on freed nodes.
  4. Comprehensive Disconnections: Added _exit_tree() to title_screen.gd, settings_menu.gd, portrait_guard.gd, combat_hud.gd, and others to cover identified leaks.
  5. Repo Hygiene: Cleaned up orphaned .gd.uid files.

Verified via GdUnit4 (174/174 tests passing).

Fixes #256


PR created automatically by Jules for task 12029236788707118407 started by @niyazmft

…_tree()

- Added _exit_tree() to multiple UI scripts to disconnect signals from Autoloads and global nodes.
- Implemented dictionary-based tracking for bound callables in `settings_panel.gd` to ensure they can be safely disconnected in Godot 4.
- Updated `defeat_modal.gd` and `victory_modal.gd` to extend `_Modal` and call `super._exit_tree()`.
- Ensured conflict warning timers in `remap_panel.gd` and block timers in `burden_modal.gd` are stored and disconnected.
- Cleaned up orphaned `.gd.uid` files generated during the process.
- Verified all changes with unit tests.

Co-authored-by: niyazmft <9331133+niyazmft@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

niyazmft and others added 2 commits June 9, 2026 23:02
…_tree()

- Added _exit_tree() to multiple UI scripts to disconnect signals from Autoloads and global nodes.
- Implemented dictionary-based tracking for bound callables in `settings_panel.gd` to ensure they can be safely disconnected in Godot 4.
- Updated `defeat_modal.gd` and `victory_modal.gd` to extend `_Modal` and call `super._exit_tree()`.
- Ensured conflict warning timers in `remap_panel.gd` and block timers in `burden_modal.gd` are stored and disconnected.
- Formatted `settings_panel.gd` with `gdformat` to satisfy CI.
- Cleaned up orphaned `.gd.uid` files.
- Verified all changes with unit tests.

Co-authored-by: niyazmft <9331133+niyazmft@users.noreply.github.com>
@niyazmft niyazmft merged commit 6deaa1b into main Jun 9, 2026
4 checks passed
@niyazmft niyazmft deleted the fix/signal-leak-epidemic-12029236788707118407 branch June 9, 2026 20:17
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.

chore(UI): signal leak epidemic — 114 connects vs 6 disconnects

1 participant