1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 03:22:55 +08:00

Fix potential crash in BeatmapLeaderboard during rapid refresh operations

This commit is contained in:
Dean Herbert 2022-07-01 15:42:35 +09:00
parent 409224560f
commit 58e25a3a01

View File

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -111,7 +112,7 @@ namespace osu.Game.Screens.Select.Leaderboards
if (Scope == BeatmapLeaderboardScope.Local)
{
subscribeToLocalScores(cancellationToken);
subscribeToLocalScores(fetchBeatmapInfo, cancellationToken);
return null;
}
@ -174,14 +175,13 @@ namespace osu.Game.Screens.Select.Leaderboards
Action = () => ScoreSelected?.Invoke(model)
};
private void subscribeToLocalScores(CancellationToken cancellationToken)
private void subscribeToLocalScores(BeatmapInfo beatmapInfo, CancellationToken cancellationToken)
{
Debug.Assert(beatmapInfo != null);
scoreSubscription?.Dispose();
scoreSubscription = null;
if (beatmapInfo == null)
return;
scoreSubscription = realm.RegisterForNotifications(r =>
r.All<ScoreInfo>().Filter($"{nameof(ScoreInfo.BeatmapInfo)}.{nameof(BeatmapInfo.ID)} == $0"
+ $" AND {nameof(ScoreInfo.Ruleset)}.{nameof(RulesetInfo.ShortName)} == $1"