1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 04:02:57 +08:00

Fix a potential crash when exiting play during the results screen transition

This commit is contained in:
Dean Herbert 2021-02-09 16:24:29 +09:00
parent a886000fbf
commit 5bd4f74ddf

View File

@ -339,7 +339,7 @@ namespace osu.Game.Screens.Play
{ {
HoldToQuit = HoldToQuit =
{ {
Action = performUserRequestedExit, Action = () => PerformExit(true),
IsPaused = { BindTarget = GameplayClockContainer.IsPaused } IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
}, },
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } }, PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
@ -363,14 +363,14 @@ namespace osu.Game.Screens.Play
FailOverlay = new FailOverlay FailOverlay = new FailOverlay
{ {
OnRetry = Restart, OnRetry = Restart,
OnQuit = performUserRequestedExit, OnQuit = () => PerformExit(true),
}, },
PauseOverlay = new PauseOverlay PauseOverlay = new PauseOverlay
{ {
OnResume = Resume, OnResume = Resume,
Retries = RestartCount, Retries = RestartCount,
OnRetry = Restart, OnRetry = Restart,
OnQuit = performUserRequestedExit, OnQuit = () => PerformExit(true),
}, },
new HotkeyExitOverlay new HotkeyExitOverlay
{ {
@ -487,14 +487,30 @@ namespace osu.Game.Screens.Play
// if a restart has been requested, cancel any pending completion (user has shown intent to restart). // if a restart has been requested, cancel any pending completion (user has shown intent to restart).
completionProgressDelegate?.Cancel(); completionProgressDelegate?.Cancel();
ValidForResume = false; if (!this.IsCurrentScreen())
{
if (!this.IsCurrentScreen()) return; // there is a chance that the exit was performed after the transition to results has started.
// we want to give the user what they want, so forcefully return to this screen (to proceed with the upwards exit process).
ValidForResume = false;
this.MakeCurrent();
}
if (userRequested) if (userRequested)
performUserRequestedExit(); {
else if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
this.Exit(); {
failAnimation.FinishTransforms(true);
return;
}
if (canPause)
{
Pause();
return;
}
}
this.Exit();
} }
private void performUserRequestedSkip() private void performUserRequestedSkip()
@ -508,20 +524,6 @@ namespace osu.Game.Screens.Play
updateSampleDisabledState(); updateSampleDisabledState();
} }
private void performUserRequestedExit()
{
if (ValidForResume && HasFailed && !FailOverlay.IsPresent)
{
failAnimation.FinishTransforms(true);
return;
}
if (canPause)
Pause();
else
this.Exit();
}
/// <summary> /// <summary>
/// Restart gameplay via a parent <see cref="PlayerLoader"/>. /// Restart gameplay via a parent <see cref="PlayerLoader"/>.
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks> /// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>