Browse Source

dispose i guess

pull/5/head
JT 2 years ago
parent
commit
e79e0ecbbe
  1. 13
      StabilityMatrix/ViewModels/LaunchViewModel.cs

13
StabilityMatrix/ViewModels/LaunchViewModel.cs

@ -20,6 +20,7 @@ namespace StabilityMatrix.ViewModels;
public partial class LaunchViewModel : ObservableObject public partial class LaunchViewModel : ObservableObject
{ {
private readonly ISettingsManager settingsManager; private readonly ISettingsManager settingsManager;
private PyVenvRunner? venvRunner;
[ObservableProperty] [ObservableProperty]
public string consoleInput = ""; public string consoleInput = "";
@ -41,7 +42,6 @@ public partial class LaunchViewModel : ObservableObject
} }
public ObservableCollection<InstalledPackage> InstalledPackages = new(); public ObservableCollection<InstalledPackage> InstalledPackages = new();
public Process? CurrentRunningProcess { get; set; }
public event EventHandler ScrollNeeded; public event EventHandler ScrollNeeded;
@ -68,10 +68,10 @@ public partial class LaunchViewModel : ObservableObject
var venvPath = Path.Combine(packagePath, "venv"); var venvPath = Path.Combine(packagePath, "venv");
// Setup venv // Setup venv
var venv = new PyVenvRunner(venvPath); venvRunner = new PyVenvRunner(venvPath);
if (!venv.Exists()) if (!venvRunner.Exists())
{ {
await venv.Setup(); await venvRunner.Setup();
} }
var onConsoleOutput = new Action<string?>(s => var onConsoleOutput = new Action<string?>(s =>
@ -97,8 +97,7 @@ public partial class LaunchViewModel : ObservableObject
var args = "\"" + Path.Combine(packagePath, "launch.py") + "\""; var args = "\"" + Path.Combine(packagePath, "launch.py") + "\"";
venv.RunDetached(args, onConsoleOutput, onExit); venvRunner.RunDetached(args, onConsoleOutput, onExit);
CurrentRunningProcess = venv.Process;
}); });
public void OnLoaded() public void OnLoaded()
@ -115,7 +114,7 @@ public partial class LaunchViewModel : ObservableObject
public void OnShutdown() public void OnShutdown()
{ {
CurrentRunningProcess?.Kill(); venvRunner?.Dispose();
} }
private void LoadPackages() private void LoadPackages()

Loading…
Cancel
Save