Use request cancellation and IsDisposed guard instead of more Schedule

This commit is contained in:
Dean Herbert
2022-09-26 16:02:33 +09:00
parent 0fa5e1b28e
commit 32d56fe3a9
2 changed files with 19 additions and 11 deletions

View File

@ -185,10 +185,15 @@ namespace osu.Game.Online.Leaderboards
if (scores != null)
this.scores.AddRange(scores);
// Schedule needs to be non-delayed here for the weird logic in refetchScores to work.
// If it is removed, the placeholder will be incorrectly updated to "no scores" rather than "retrieving".
// This whole flow should be refactored in the future.
Scheduler.Add(applyNewScores, false);
// Non-delayed schedule may potentially run inline (due to IsMainThread check passing) after leaderboard is disposed.
// This is guarded against in BeatmapLeaderboard via web request cancellation, but let's be extra safe.
if (!IsDisposed)
{
// Schedule needs to be non-delayed here for the weird logic in refetchScores to work.
// If it is removed, the placeholder will be incorrectly updated to "no scores" rather than "retrieving".
// This whole flow should be refactored in the future.
Scheduler.Add(applyNewScores, false);
}
void applyNewScores()
{