mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 17:52:54 +08:00
Safely cancel the completion task on restart or immediate exit
This commit is contained in:
parent
bf0f6e1053
commit
dd701eaa62
@ -255,7 +255,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private void performImmediateExit()
|
private void performImmediateExit()
|
||||||
{
|
{
|
||||||
// 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).
|
||||||
onCompletionEvent = null;
|
onCompletionEvent?.Cancel();
|
||||||
|
|
||||||
ValidForResume = false;
|
ValidForResume = false;
|
||||||
|
|
||||||
@ -275,12 +275,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
sampleRestart?.Play();
|
sampleRestart?.Play();
|
||||||
|
|
||||||
// if a restart has been requested, cancel any pending completion (user has shown intent to restart).
|
|
||||||
onCompletionEvent = null;
|
|
||||||
|
|
||||||
ValidForResume = false;
|
|
||||||
RestartRequested?.Invoke();
|
RestartRequested?.Invoke();
|
||||||
this.Exit();
|
performImmediateExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate onCompletionEvent;
|
private ScheduledDelegate onCompletionEvent;
|
||||||
@ -306,8 +302,6 @@ namespace osu.Game.Screens.Play
|
|||||||
scoreManager.Import(score).Wait();
|
scoreManager.Import(score).Wait();
|
||||||
|
|
||||||
this.Push(CreateResults(score));
|
this.Push(CreateResults(score));
|
||||||
|
|
||||||
onCompletionEvent = null;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -471,9 +465,9 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public override bool OnExiting(IScreen next)
|
public override bool OnExiting(IScreen next)
|
||||||
{
|
{
|
||||||
if (onCompletionEvent != null)
|
if (onCompletionEvent != null && !onCompletionEvent.Cancelled && !onCompletionEvent.Completed)
|
||||||
|
// proceed to result screen if beatmap already finished playing
|
||||||
{
|
{
|
||||||
// Proceed to result screen if beatmap already finished playing
|
|
||||||
onCompletionEvent.RunTask();
|
onCompletionEvent.RunTask();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user