From 1025e5b3cc756b1cbd01216be157b3e0b270225f Mon Sep 17 00:00:00 2001 From: smallketchup82 Date: Wed, 26 Jun 2024 21:55:22 -0400 Subject: [PATCH] rewrite the restart function --- osu.Desktop/OsuGameDesktop.cs | 11 ++++++++--- .../Screens/Setup/TournamentSwitcher.cs | 3 +-- osu.Game/OsuGameBase.cs | 2 +- .../Settings/Sections/Graphics/RendererSettings.cs | 3 +-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 245d00dc53..3019aefdc0 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -105,18 +105,23 @@ namespace osu.Desktop return new VeloUpdateManager(); } - public override bool RestartAppWhenExited() + public override bool RestartApp() { try { - Process.Start(Process.GetCurrentProcess().MainModule?.FileName ?? throw new InvalidOperationException()); + var startInfo = new ProcessStartInfo + { + FileName = Process.GetCurrentProcess().MainModule!.FileName, + UseShellExecute = true + }; + Process.Start(startInfo); Environment.Exit(0); return true; } catch (Exception e) { Logger.Error(e, "Failed to restart application"); - return base.RestartAppWhenExited(); + return base.RestartApp(); } } diff --git a/osu.Game.Tournament/Screens/Setup/TournamentSwitcher.cs b/osu.Game.Tournament/Screens/Setup/TournamentSwitcher.cs index e55cbc2dbb..69ead451ba 100644 --- a/osu.Game.Tournament/Screens/Setup/TournamentSwitcher.cs +++ b/osu.Game.Tournament/Screens/Setup/TournamentSwitcher.cs @@ -31,8 +31,7 @@ namespace osu.Game.Tournament.Screens.Setup Action = () => { - game.RestartAppWhenExited(); - game.AttemptExit(); + game.RestartApp(); }; folderButton.Action = () => storage.PresentExternally(); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 5533ee8337..db603f0046 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -513,7 +513,7 @@ namespace osu.Game /// If supported by the platform, the game will automatically restart after the next exit. /// /// Whether a restart operation was queued. - public virtual bool RestartAppWhenExited() => false; + public virtual bool RestartApp() => false; public bool Migrate(string path) { diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs index a8b127d522..17e345c2c8 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/RendererSettings.cs @@ -67,9 +67,8 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics if (r.NewValue == RendererType.Automatic && automaticRendererInUse) return; - if (game?.RestartAppWhenExited() == true) + if (game?.RestartApp() == true) { - game.AttemptExit(); } else {