mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 10:22:56 +08:00
Merge pull request #18964 from peppy/fix-beatmap-leaderboard-null
Fix potential crash in `BeatmapLeaderboard` during rapid refresh operations
This commit is contained in:
commit
ee963f8aa7
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -111,7 +112,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
|
|
||||||
if (Scope == BeatmapLeaderboardScope.Local)
|
if (Scope == BeatmapLeaderboardScope.Local)
|
||||||
{
|
{
|
||||||
subscribeToLocalScores(cancellationToken);
|
subscribeToLocalScores(fetchBeatmapInfo, cancellationToken);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,14 +175,13 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
Action = () => ScoreSelected?.Invoke(model)
|
Action = () => ScoreSelected?.Invoke(model)
|
||||||
};
|
};
|
||||||
|
|
||||||
private void subscribeToLocalScores(CancellationToken cancellationToken)
|
private void subscribeToLocalScores(BeatmapInfo beatmapInfo, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
Debug.Assert(beatmapInfo != null);
|
||||||
|
|
||||||
scoreSubscription?.Dispose();
|
scoreSubscription?.Dispose();
|
||||||
scoreSubscription = null;
|
scoreSubscription = null;
|
||||||
|
|
||||||
if (beatmapInfo == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
scoreSubscription = realm.RegisterForNotifications(r =>
|
scoreSubscription = realm.RegisterForNotifications(r =>
|
||||||
r.All<ScoreInfo>().Filter($"{nameof(ScoreInfo.BeatmapInfo)}.{nameof(BeatmapInfo.ID)} == $0"
|
r.All<ScoreInfo>().Filter($"{nameof(ScoreInfo.BeatmapInfo)}.{nameof(BeatmapInfo.ID)} == $0"
|
||||||
+ $" AND {nameof(ScoreInfo.Ruleset)}.{nameof(RulesetInfo.ShortName)} == $1"
|
+ $" AND {nameof(ScoreInfo.Ruleset)}.{nameof(RulesetInfo.ShortName)} == $1"
|
||||||
|
Loading…
Reference in New Issue
Block a user