From fff3f1c544e3ed610ca3ff2d07431bbf10330440 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Fri, 10 Oct 2025 23:22:11 +1000 Subject: [PATCH] dispose of isDirty subscription when tab is freed --- .../Features/CodeEditor/CodeEditorPanel.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs index fc55fc7..6962ff9 100644 --- a/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs +++ b/src/SharpIDE.Godot/Features/CodeEditor/CodeEditorPanel.cs @@ -74,17 +74,19 @@ public partial class CodeEditorPanel : MarginContainer _tabContainer.SetTabTitle(newTabIndex, file.Name); _tabContainer.SetTabTooltip(newTabIndex, file.Path); _tabContainer.CurrentTab = newTabIndex; - }); - file.IsDirty.Skip(1).SubscribeOnThreadPool().SubscribeAwait(async (isDirty, ct) => - { - //GD.Print($"File dirty state changed: {file.Path} is now {(isDirty ? "dirty" : "clean")}"); - await this.InvokeAsync(() => + + file.IsDirty.Skip(1).SubscribeOnThreadPool().SubscribeAwait(async (isDirty, ct) => { - var tabIndex = newTab.GetIndex(); - var title = file.Name + (isDirty ? " (*)" : ""); - _tabContainer.SetTabTitle(tabIndex, title); - }); + //GD.Print($"File dirty state changed: {file.Path} is now {(isDirty ? "dirty" : "clean")}"); + await this.InvokeAsync(() => + { + var tabIndex = newTab.GetIndex(); + var title = file.Name + (isDirty ? " (*)" : ""); + _tabContainer.SetTabTitle(tabIndex, title); + }); + }).AddTo(newTab); // needs to be on ui thread }); + await newTab.SetSharpIdeFile(file); if (fileLinePosition is not null) await this.InvokeAsync(() => newTab.SetFileLinePosition(fileLinePosition.Value)); }