1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 21:12:55 +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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading;
using JetBrains.Annotations; using JetBrains.Annotations;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -85,6 +86,8 @@ namespace osu.Game.Screens.Select
private WorkingBeatmap beatmap; private WorkingBeatmap beatmap;
private CancellationTokenSource cancellationSource;
public WorkingBeatmap Beatmap public WorkingBeatmap Beatmap
{ {
get => beatmap; get => beatmap;
@ -93,10 +96,12 @@ namespace osu.Game.Screens.Select
if (beatmap == value) return; if (beatmap == value) return;
beatmap = value; beatmap = value;
cancellationSource?.Cancel();
cancellationSource = new CancellationTokenSource();
beatmapDifficulty?.UnbindAll(); beatmapDifficulty?.UnbindAll();
beatmapDifficulty = difficultyManager.GetBindableDifficulty(beatmap.BeatmapInfo); beatmapDifficulty = difficultyManager.GetBindableDifficulty(beatmap.BeatmapInfo, cancellationSource.Token);
beatmapDifficulty.BindValueChanged(_ => updateDisplay()); beatmapDifficulty.BindValueChanged(_ => Schedule(updateDisplay));
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 class BufferedWedgeInfo : BufferedContainer
{ {
public OsuSpriteText VersionLabel { get; private set; } public OsuSpriteText VersionLabel { get; private set; }