Skip to content

Commit

Permalink
fix: Studio potentially not getting closed sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Oct 8, 2024
1 parent 10d3621 commit 7d17783
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions CelesteTAS-EverestInterop/Source/EverestInterop/StudioHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class StudioHelper {

// These values will automatically get filled in by the Build.yml/Release.yml actions
private const bool DoubleZipArchive = false; //DOUBLE_ZIP_ARCHIVE
public const string CurrentStudioVersion = "3.2.1";
public const string CurrentStudioVersion = "##STUDIO_VERSION##";

private const string DownloadURL_Windows_x64 = "##URL_WINDOWS_x64##";
private const string DownloadURL_Linux_x64 = "##URL_LINUX_x64##";
Expand Down Expand Up @@ -93,11 +93,15 @@ private static void Load() {
$"Celeste Studio version mismatch: Expected '{CurrentStudioVersion}', found '{installedVersion}'. Installing current version...".Log();

Task.Run(async () => {
// Kill all Studio instances to avoid issues with file usage
foreach (var process in Process.GetProcesses().Where(process => process.ProcessName is "CelesteStudio" or "Celeste Studio")) {
// Close all Studio instances to avoid issues with file usage
foreach (var process in Process.GetProcesses().Where(process => process.ProcessName is "CelesteStudio" or "CelesteStudio.WPF" or "CelesteStudio.GTK" or "CelesteStudio.Mac" or "Celeste Studio")) {
$"Closing process {process} ({process.Id})...".Log(LogLevel.Verbose);
process.Terminate();
await process.WaitForExitAsync().WaitAsync(TimeSpan.FromSeconds(10.0f)).ConfigureAwait(false);

// Make sure it's _really_ closed
process.Kill();
await process.WaitForExitAsync().WaitAsync(TimeSpan.FromSeconds(5.0f)).ConfigureAwait(false);
"Process terminated".Log(LogLevel.Verbose);
}

Expand Down
4 changes: 4 additions & 0 deletions Studio/CelesteStudio/Studio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public Studio(string[] args, Action<Window> windowCreationCallback) {
Console.WriteLine($"Closing process {process.ProcessName} ({process.Id})...");
process.Terminate();
process.WaitForExit(TimeSpan.FromSeconds(10.0f));

// Make sure it's _really_ closed
process.Kill();
process.WaitForExit(TimeSpan.FromSeconds(5.0f));
}

// Ensure config directory exists
Expand Down

0 comments on commit 7d17783

Please sign in to comment.