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

Fix incorrect CancellationToken usage

Apparently I wrote the BDL system and don't know how this works. I
believe you need `CancellationToken?` or CanBeNull=true, however that doesn't actually
play well when actually using the token in code...
This commit is contained in:
smoogipoo 2021-10-05 12:07:41 +09:00
parent 593da79bbc
commit 5624dd9af6

View File

@ -49,20 +49,22 @@ namespace osu.Game.Screens.Play.HUD
[CanBeNull]
private Ruleset gameplayRuleset;
private readonly CancellationTokenSource loadCancellationSource = new CancellationTokenSource();
public PerformancePointsCounter()
{
Current.Value = DisplayedCount = 0;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours, BeatmapDifficultyCache difficultyCache, CancellationToken cancellationToken)
private void load(OsuColour colours, BeatmapDifficultyCache difficultyCache)
{
Colour = colours.BlueLighter;
if (gameplayState != null)
{
gameplayRuleset = gameplayState.Ruleset;
difficultyCache.GetTimedDifficultyAttributesAsync(new GameplayWorkingBeatmap(gameplayState.Beatmap), gameplayRuleset, gameplayState.Mods.ToArray(), cancellationToken)
difficultyCache.GetTimedDifficultyAttributesAsync(new GameplayWorkingBeatmap(gameplayState.Beatmap), gameplayRuleset, gameplayState.Mods.ToArray(), loadCancellationSource.Token)
.ContinueWith(r => Schedule(() => timedAttributes = r.Result), TaskContinuationOptions.OnlyOnRanToCompletion);
}
}
@ -101,6 +103,8 @@ namespace osu.Game.Screens.Play.HUD
if (scoreProcessor != null)
scoreProcessor.NewJudgement -= onNewJudgement;
loadCancellationSource?.Cancel();
}
private class TextComponent : CompositeDrawable, IHasText