1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 19:54:15 +08:00

Fix cancelling a restart for update still quitting the game after one minutes (#36950)

Closes #36816.

- [x] Self review / testing.
This commit is contained in:
Dean Herbert
2026-03-18 16:48:07 +09:00
committed by GitHub
Unverified
parent f97d77c0b7
commit e0ccdfae94
6 changed files with 28 additions and 10 deletions
+1 -3
View File
@@ -5,7 +5,6 @@ using System;
using System.IO;
using System.Reflection;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using Microsoft.Win32;
using osu.Desktop.Performance;
using osu.Desktop.Security;
@@ -20,7 +19,6 @@ using osu.Framework.Allocation;
using osu.Game.Configuration;
using osu.Game.IO;
using osu.Game.IPC;
using osu.Game.Online.Multiplayer;
using osu.Game.Performance;
using osu.Game.Utils;
@@ -123,7 +121,7 @@ namespace osu.Desktop
public override bool RestartAppWhenExited()
{
Task.Run(() => Velopack.UpdateExe.Start(waitPid: (uint)Environment.ProcessId)).FireAndForget();
RestartOnExitAction = () => Velopack.UpdateExe.Start(waitPid: (uint)Environment.ProcessId);
return true;
}
+4 -4
View File
@@ -146,11 +146,11 @@ namespace osu.Desktop.Updater
action();
}
private void restartToApplyUpdate(Velopack.UpdateManager updateManager, UpdateInfo update) => Task.Run(async () =>
private void restartToApplyUpdate(Velopack.UpdateManager updateManager, UpdateInfo update)
{
await updateManager.WaitExitThenApplyUpdatesAsync(update.TargetFullRelease).ConfigureAwait(false);
Schedule(() => game.AttemptExit());
});
game.RestartOnExitAction = () => updateManager.WaitExitThenApplyUpdates(update.TargetFullRelease);
game.AttemptExit();
}
private static void log(string text) => Logger.Log($"VelopackUpdateManager: {text}");
}
+1 -1
View File
@@ -193,7 +193,7 @@ namespace osu.Game
protected readonly Bindable<LocalUserPlayingState> UserPlayingState = new Bindable<LocalUserPlayingState>();
protected OsuScreenStack ScreenStack;
public OsuScreenStack ScreenStack { get; private set; }
protected BackButton BackButton => screenStackFooter.BackButton;
protected ScreenFooter ScreenFooter => screenStackFooter.Footer;
+21
View File
@@ -10,6 +10,7 @@ using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
@@ -517,6 +518,8 @@ namespace osu.Game
host.ExceptionThrown += onExceptionThrown;
}
#region Exit handling
/// <summary>
/// Use to programatically exit the game as if the user was triggering via alt-f4.
/// By default, will keep persisting until an exit occurs (exit may be blocked multiple times).
@@ -530,12 +533,28 @@ namespace osu.Game
Scheduler.AddDelayed(AttemptExit, 2000);
}
/// <summary>
/// An action that restarts the application after it has exited.
/// </summary>
[CanBeNull]
public Action RestartOnExitAction { private get; set; }
/// <summary>
/// Signals that the application should not be restarted after it is exited.
/// </summary>
public void CancelRestartOnExit()
{
RestartOnExitAction = null;
}
/// <summary>
/// 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;
#endregion
/// <summary>
/// Perform migration of user data to a specified path.
/// </summary>
@@ -742,6 +761,8 @@ namespace osu.Game
if (Host != null)
Host.ExceptionThrown -= onExceptionThrown;
RestartOnExitAction?.Invoke();
}
ControlPointInfo IBeatSyncProvider.ControlPoints => Beatmap.Value.BeatmapLoaded ? Beatmap.Value.Beatmap.ControlPointInfo : null;
+1
View File
@@ -429,6 +429,7 @@ namespace osu.Game.Screens.Menu
}, () =>
{
holdToExitGameOverlay.Abort();
Game.CancelRestartOnExit();
}));
}
@@ -124,8 +124,6 @@ namespace osu.Game.Tests.Visual
{
public new const float SIDE_OVERLAY_OFFSET_RATIO = OsuGame.SIDE_OVERLAY_OFFSET_RATIO;
public new ScreenStack ScreenStack => base.ScreenStack;
public RealmAccess Realm => Dependencies.Get<RealmAccess>();
public new GlobalCursorDisplay GlobalCursorDisplay => base.GlobalCursorDisplay;