Skip to content

Commit

Permalink
Fix up restarting
Browse files Browse the repository at this point in the history
Earlier I changed the restarting logic to not wait until the program
exits and instead try to facilitate restarting alone. This did not work,
and it became clear we'd need Velopack to do the restarting. This
reverts back and supposedly brings restarting logic in line with how
Velopack does it
  • Loading branch information
smallketchup82 committed Jul 4, 2024
1 parent fae8f5f commit cae3607
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
13 changes: 3 additions & 10 deletions osu.Desktop/OsuGameDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.

using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;
Expand Down Expand Up @@ -104,23 +103,17 @@ protected override UpdateManager CreateUpdateManager()
return new VeloUpdateManager();
}

public override bool RestartApp()
public override bool RestartAppWhenExited()
{
try
{
var startInfo = new ProcessStartInfo
{
FileName = Process.GetCurrentProcess().MainModule!.FileName,
UseShellExecute = true
};
Process.Start(startInfo);
base.AttemptExit();
Velopack.UpdateExe.Start(null, true);
return true;
}
catch (Exception e)
{
Logger.Error(e, "Failed to restart application");
return base.RestartApp();
return base.RestartAppWhenExited();
}
}

Expand Down
3 changes: 2 additions & 1 deletion osu.Game.Tournament/Screens/Setup/TournamentSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ private void load(TournamentStorage storage)

Action = () =>
{
game.RestartApp();
game.RestartAppWhenExited();
game.AttemptExit();
};
folderButton.Action = () => storage.PresentExternally();

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/OsuGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ public virtual void AttemptExit()
/// 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 RestartApp() => false;
public virtual bool RestartAppWhenExited() => false;

public bool Migrate(string path)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, IDi
if (r.NewValue == RendererType.Automatic && automaticRendererInUse)
return;

if (game?.RestartApp() == true)
if (game?.RestartAppWhenExited() == true)
{
game.AttemptExit();
}
else
{
Expand Down

0 comments on commit cae3607

Please sign in to comment.