Add current screen checks for added safety

This commit is contained in:
Dan Balasescu 2022-03-10 20:02:58 +09:00
parent 2d135e5be6
commit 885cb3ce5b
1 changed files with 11 additions and 1 deletions

View File

@ -10,6 +10,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
@ -171,6 +172,9 @@ private void adjustLeaderboardPosition()
private void onMatchStarted() => Scheduler.Add(() =>
{
if (!this.IsCurrentScreen())
return;
loadingDisplay.Hide();
base.StartGameplay();
});
@ -179,7 +183,13 @@ private void onResultsReady()
{
// Schedule is required to ensure that `TaskCompletionSource.SetResult` is not called more than once.
// A scenario where this can occur is if this instance is not immediately disposed (ie. async disposal queue).
Schedule(() => resultsReady.SetResult(true));
Schedule(() =>
{
if (!this.IsCurrentScreen())
return;
resultsReady.SetResult(true);
});
}
protected override async Task PrepareScoreForResultsAsync(Score score)