Fix crash on exiting player during results transition

This commit is contained in:
Dean Herbert 2018-12-13 16:17:24 +09:00
parent f29c6987d2
commit 71e5ce59da
1 changed files with 11 additions and 3 deletions

View File

@ -170,7 +170,7 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
{ {
Retries = RestartCount, Retries = RestartCount,
OnRetry = Restart, OnRetry = Restart,
OnQuit = Exit, OnQuit = performUserRequestedExit,
CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded, CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded,
Children = new[] Children = new[]
{ {
@ -211,7 +211,7 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
failOverlay = new FailOverlay failOverlay = new FailOverlay
{ {
OnRetry = Restart, OnRetry = Restart,
OnQuit = Exit, OnQuit = performUserRequestedExit,
}, },
new HotkeyRetryOverlay new HotkeyRetryOverlay
{ {
@ -225,7 +225,7 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config)
} }
}; };
hudOverlay.HoldToQuit.Action = Exit; hudOverlay.HoldToQuit.Action = performUserRequestedExit;
hudOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded); hudOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded);
RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused); RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused);
@ -250,8 +250,16 @@ private void applyRateFromMods()
mod.ApplyToClock(sourceClock); mod.ApplyToClock(sourceClock);
} }
private void performUserRequestedExit()
{
if (!IsCurrentScreen) return;
Exit();
}
public void Restart() public void Restart()
{ {
if (!IsCurrentScreen) return;
sampleRestart?.Play(); sampleRestart?.Play();
ValidForResume = false; ValidForResume = false;
RestartRequested?.Invoke(); RestartRequested?.Invoke();