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:
parent
0ee89183cc
commit
1025e5b3cc
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,7 @@ namespace osu.Game.Tournament.Screens.Setup
|
||||
|
||||
Action = () =>
|
||||
{
|
||||
game.RestartAppWhenExited();
|
||||
game.AttemptExit();
|
||||
game.RestartApp();
|
||||
};
|
||||
folderButton.Action = () => storage.PresentExternally();
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user