1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 00:02: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();
}
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();
}
}

View File

@ -31,8 +31,7 @@ namespace osu.Game.Tournament.Screens.Setup
Action = () =>
{
game.RestartAppWhenExited();
game.AttemptExit();
game.RestartApp();
};
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.
/// </summary>
/// <returns>Whether a restart operation was queued.</returns>
public virtual bool RestartAppWhenExited() => false;
public virtual bool RestartApp() => false;
public bool Migrate(string path)
{

View File

@ -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
{