dispose of isDirty subscription when tab is freed

This commit is contained in:
Matt Parker
2025-10-10 23:22:11 +10:00
parent c415a095d1
commit fff3f1c544

View File

@@ -74,7 +74,7 @@ public partial class CodeEditorPanel : MarginContainer
_tabContainer.SetTabTitle(newTabIndex, file.Name); _tabContainer.SetTabTitle(newTabIndex, file.Name);
_tabContainer.SetTabTooltip(newTabIndex, file.Path); _tabContainer.SetTabTooltip(newTabIndex, file.Path);
_tabContainer.CurrentTab = newTabIndex; _tabContainer.CurrentTab = newTabIndex;
});
file.IsDirty.Skip(1).SubscribeOnThreadPool().SubscribeAwait(async (isDirty, ct) => file.IsDirty.Skip(1).SubscribeOnThreadPool().SubscribeAwait(async (isDirty, ct) =>
{ {
//GD.Print($"File dirty state changed: {file.Path} is now {(isDirty ? "dirty" : "clean")}"); //GD.Print($"File dirty state changed: {file.Path} is now {(isDirty ? "dirty" : "clean")}");
@@ -84,7 +84,9 @@ public partial class CodeEditorPanel : MarginContainer
var title = file.Name + (isDirty ? " (*)" : ""); var title = file.Name + (isDirty ? " (*)" : "");
_tabContainer.SetTabTitle(tabIndex, title); _tabContainer.SetTabTitle(tabIndex, title);
}); });
}).AddTo(newTab); // needs to be on ui thread
}); });
await newTab.SetSharpIdeFile(file); await newTab.SetSharpIdeFile(file);
if (fileLinePosition is not null) await this.InvokeAsync(() => newTab.SetFileLinePosition(fileLinePosition.Value)); if (fileLinePosition is not null) await this.InvokeAsync(() => newTab.SetFileLinePosition(fileLinePosition.Value));
} }