From d72412d24d6b68c137cdd247f553e07ae3eab4cd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 7 Jan 2019 19:28:46 +0900 Subject: [PATCH] Fix leaderboard not correctly handling cancellation --- osu.Game/Online/Leaderboards/Leaderboard.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/Leaderboards/Leaderboard.cs b/osu.Game/Online/Leaderboards/Leaderboard.cs index f3bf16a05f..2aeb503224 100644 --- a/osu.Game/Online/Leaderboards/Leaderboard.cs +++ b/osu.Game/Online/Leaderboards/Leaderboard.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using osu.Framework.Allocation; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -30,6 +31,7 @@ namespace osu.Game.Online.Leaderboards private readonly LoadingAnimation loading; private ScheduledDelegate showScoresDelegate; + private CancellationTokenSource showScoresCancellationSource; private bool scoresLoadedOnce; @@ -60,6 +62,8 @@ namespace osu.Game.Online.Leaderboards // schedule because we may not be loaded yet (LoadComponentAsync complains). showScoresDelegate?.Cancel(); + showScoresCancellationSource?.Cancel(); + if (!IsLoaded) showScoresDelegate = Schedule(showScores); else @@ -77,7 +81,7 @@ namespace osu.Game.Online.Leaderboards } scrollContainer.ScrollTo(0f, false); - }); + }, (showScoresCancellationSource = new CancellationTokenSource()).Token); } }