1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 18:32:56 +08:00

Fix potential errors thrown during beatmap leaderboard display due to incorrect beatmap reference

Specifically, the global `BeatmapInfo` is referenced inside the web
request's success callback, and used to attempt population via methods
which expect non-null beatmap inputs.

Closes #16211.
This commit is contained in:
Dean Herbert 2021-12-22 17:24:01 +09:00
parent cfdfe81afb
commit 5b3a154431

View File

@ -115,7 +115,9 @@ namespace osu.Game.Screens.Select.Leaderboards
var cancellationToken = loadCancellationSource.Token;
if (BeatmapInfo == null)
var fetchBeatmapInfo = BeatmapInfo;
if (fetchBeatmapInfo == null)
{
PlaceholderState = PlaceholderState.NoneSelected;
return null;
@ -124,7 +126,7 @@ namespace osu.Game.Screens.Select.Leaderboards
if (Scope == BeatmapLeaderboardScope.Local)
{
var scores = scoreManager
.QueryScores(s => !s.DeletePending && s.BeatmapInfo.ID == BeatmapInfo.ID && s.Ruleset.ID == ruleset.Value.ID);
.QueryScores(s => !s.DeletePending && s.BeatmapInfo.ID == fetchBeatmapInfo.ID && s.Ruleset.ID == ruleset.Value.ID);
if (filterMods && !mods.Value.Any())
{
@ -151,7 +153,7 @@ namespace osu.Game.Screens.Select.Leaderboards
return null;
}
if (BeatmapInfo.OnlineID == null || BeatmapInfo?.Status <= BeatmapOnlineStatus.Pending)
if (fetchBeatmapInfo.OnlineID == null || fetchBeatmapInfo.Status <= BeatmapOnlineStatus.Pending)
{
PlaceholderState = PlaceholderState.Unavailable;
return null;
@ -171,18 +173,18 @@ namespace osu.Game.Screens.Select.Leaderboards
else if (filterMods)
requestMods = mods.Value;
var req = new GetScoresRequest(BeatmapInfo, ruleset.Value ?? BeatmapInfo.Ruleset, Scope, requestMods);
var req = new GetScoresRequest(fetchBeatmapInfo, ruleset.Value ?? fetchBeatmapInfo.Ruleset, Scope, requestMods);
req.Success += r =>
{
scoreManager.OrderByTotalScoreAsync(r.Scores.Select(s => s.CreateScoreInfo(rulesets, BeatmapInfo)).ToArray(), cancellationToken)
scoreManager.OrderByTotalScoreAsync(r.Scores.Select(s => s.CreateScoreInfo(rulesets, fetchBeatmapInfo)).ToArray(), cancellationToken)
.ContinueWith(ordered => Schedule(() =>
{
if (cancellationToken.IsCancellationRequested)
return;
scoresCallback?.Invoke(ordered.Result);
TopScore = r.UserScore?.CreateScoreInfo(rulesets, BeatmapInfo);
TopScore = r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo);
}), TaskContinuationOptions.OnlyOnRanToCompletion);
};