1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-21 06:42:54 +08:00

rewrite the restart function

This commit is contained in:
smallketchup82 2024-06-26 21:55:22 -04:00
parent 0ee89183cc
commit 1025e5b3cc
No known key found for this signature in database
GPG Key ID: 7345B7C561243F1E
4 changed files with 11 additions and 8 deletions

View File

@ -105,18 +105,23 @@ namespace osu.Desktop
return new VeloUpdateManager(); return new VeloUpdateManager();
} }
public override bool RestartAppWhenExited() public override bool RestartApp()
{ {
try 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); Environment.Exit(0);
return true; return true;
} }
catch (Exception e) catch (Exception e)
{ {
Logger.Error(e, "Failed to restart application"); Logger.Error(e, "Failed to restart application");
return base.RestartAppWhenExited(); return base.RestartApp();
} }
} }

View File

@ -31,8 +31,7 @@ namespace osu.Game.Tournament.Screens.Setup
Action = () => Action = () =>
{ {
game.RestartAppWhenExited(); game.RestartApp();
game.AttemptExit();
}; };
folderButton.Action = () => storage.PresentExternally(); folderButton.Action = () => storage.PresentExternally();

View File

@ -513,7 +513,7 @@ namespace osu.Game
/// If supported by the platform, the game will automatically restart after the next exit. /// If supported by the platform, the game will automatically restart after the next exit.
/// </summary> /// </summary>
/// <returns>Whether a restart operation was queued.</returns> /// <returns>Whether a restart operation was queued.</returns>
public virtual bool RestartAppWhenExited() => false; public virtual bool RestartApp() => false;
public bool Migrate(string path) public bool Migrate(string path)
{ {

View File

@ -67,9 +67,8 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
if (r.NewValue == RendererType.Automatic && automaticRendererInUse) if (r.NewValue == RendererType.Automatic && automaticRendererInUse)
return; return;
if (game?.RestartAppWhenExited() == true) if (game?.RestartApp() == true)
{ {
game.AttemptExit();
} }
else else
{ {