Make DI services scoped

This commit is contained in:
Matt Parker
2025-10-18 16:20:57 +10:00
parent d90f0e6c28
commit 69d72307f0
4 changed files with 43 additions and 24 deletions

View File

@@ -21,8 +21,6 @@ public partial class IdeWindow : Control
private IdeRoot? _ideRoot;
private SlnPicker? _slnPicker;
[Inject] private readonly IdeOpenTabsFileManager _openTabsFileManager = null!;
public override void _Ready()
{
GD.Print("IdeWindow _Ready called");
@@ -31,7 +29,6 @@ public partial class IdeWindow : Control
MSBuildLocator.RegisterDefaults();
GodotServiceDefaults.AddServiceDefaults();
Singletons.AppState = AppStateLoader.LoadAppStateFromConfigFile();
GetWindow().FocusExited += OnFocusExited;
//GetWindow().SetMinSize(new Vector2I(1152, 648));
Callable.From(() => PickSolution(true)).CallDeferred();
}
@@ -47,12 +44,6 @@ public partial class IdeWindow : Control
// PrintOrphanNodes();
}
// TODO: Problematic, as this is called even when the focus shifts to an embedded subwindow, such as a popup
private void OnFocusExited()
{
_ = Task.GodotRun(async () => await _openTabsFileManager.SaveAllOpenFilesAsync());
}
public void PickSolution(bool fullscreen = false)
{
if (_slnPicker is not null) throw new InvalidOperationException("Solution picker is already active");
@@ -109,7 +100,8 @@ public partial class IdeWindow : Control
{
GetWindow().Mode = Window.ModeEnum.Maximized;
}
_ideRoot = ideRoot;
_ideRoot = ideRoot; // This has no DI services, until it is added to the scene tree
GetNode<DiAutoload>("/root/DiAutoload").ResetScope();
AddChild(ideRoot);
});
});