From 4e93a7ae6d2eb3b4b8dc0d8ed0eb19f094ec6ffd Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Mon, 27 Oct 2025 18:53:37 +1000 Subject: [PATCH] dispose of event subs --- .../CodeEditor/SharpIdeCodeEdit_SymbolHover.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit_SymbolHover.cs b/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit_SymbolHover.cs index 491899c..17b53dc 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit_SymbolHover.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/SharpIdeCodeEdit_SymbolHover.cs @@ -12,7 +12,6 @@ public partial class SharpIdeCodeEdit private void CloseSymbolHoverWindow() { _symbolHoverTimer?.EmitSignal(Timer.SignalName.Timeout); - _symbolHoverTimer = null; } // This method is a bit of a disaster - we create an additional invisible Window, so that the tooltip window doesn't disappear while the mouse is over the hovered symbol @@ -82,13 +81,20 @@ public partial class SharpIdeCodeEdit { tooltipWindow.QueueFree(); symbolNameHoverWindow.QueueFree(); + tooltipWindow.MouseExited -= StartTimer; + tooltipWindow.MouseEntered -= StopTimer; + symbolNameHoverWindow.MouseExited -= StartTimer; + symbolNameHoverWindow.MouseEntered -= StopTimer; + _symbolHoverTimer = null; }; _symbolHoverTimer = timer; - tooltipWindow.MouseExited += () => timer.Start(); - tooltipWindow.MouseEntered += () => timer.Stop(); - symbolNameHoverWindow.MouseExited += () => timer.Start(); - symbolNameHoverWindow.MouseEntered += () => timer.Stop(); + void StartTimer() => timer.Start(); + void StopTimer() => timer.Stop(); + tooltipWindow.MouseExited += StartTimer; + tooltipWindow.MouseEntered += StopTimer; + symbolNameHoverWindow.MouseExited += StartTimer; + symbolNameHoverWindow.MouseEntered += StopTimer; var styleBox = new StyleBoxFlat {