1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Fix LoadComponentAsync calls potentially occuring after beatmap wedge disposal

As seen in https://ci.appveyor.com/project/peppy/osu/builds/36109658/tests.

Also adds cancellation logic for good measure.
This commit is contained in:
Dean Herbert 2020-11-03 19:53:35 +09:00
parent 2d1db6a22d
commit d788931661

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using JetBrains.Annotations;
using osuTK;
using osuTK.Graphics;
@ -85,6 +86,8 @@ namespace osu.Game.Screens.Select
private WorkingBeatmap beatmap;
private CancellationTokenSource cancellationSource;
public WorkingBeatmap Beatmap
{
get => beatmap;
@ -93,10 +96,12 @@ namespace osu.Game.Screens.Select
if (beatmap == value) return;
beatmap = value;
cancellationSource?.Cancel();
cancellationSource = new CancellationTokenSource();
beatmapDifficulty?.UnbindAll();
beatmapDifficulty = difficultyManager.GetBindableDifficulty(beatmap.BeatmapInfo);
beatmapDifficulty.BindValueChanged(_ => updateDisplay());
beatmapDifficulty = difficultyManager.GetBindableDifficulty(beatmap.BeatmapInfo, cancellationSource.Token);
beatmapDifficulty.BindValueChanged(_ => Schedule(updateDisplay));
updateDisplay();
}
@ -137,6 +142,12 @@ namespace osu.Game.Screens.Select
});
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
cancellationSource?.Cancel();
}
public class BufferedWedgeInfo : BufferedContainer
{
public OsuSpriteText VersionLabel { get; private set; }