From 71e5ce59da01307d444712e0176193d91b5def0b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 13 Dec 2018 16:17:24 +0900 Subject: [PATCH] Fix crash on exiting player during results transition --- osu.Game/Screens/Play/Player.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index bf44e9e636..19b49b099c 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -170,7 +170,7 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config) { Retries = RestartCount, OnRetry = Restart, - OnQuit = Exit, + OnQuit = performUserRequestedExit, CheckCanPause = () => AllowPause && ValidForResume && !HasFailed && !RulesetContainer.HasReplayLoaded, Children = new[] { @@ -211,7 +211,7 @@ private void load(AudioManager audio, APIAccess api, OsuConfigManager config) failOverlay = new FailOverlay { OnRetry = Restart, - OnQuit = Exit, + OnQuit = performUserRequestedExit, }, 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); RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused); @@ -250,8 +250,16 @@ private void applyRateFromMods() mod.ApplyToClock(sourceClock); } + private void performUserRequestedExit() + { + if (!IsCurrentScreen) return; + Exit(); + } + public void Restart() { + if (!IsCurrentScreen) return; + sampleRestart?.Play(); ValidForResume = false; RestartRequested?.Invoke();