diff --git a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs
index 2183cf00df..291239e350 100644
--- a/osu.Game/Beatmaps/BeatmapDifficultyCache.cs
+++ b/osu.Game/Beatmaps/BeatmapDifficultyCache.cs
@@ -95,9 +95,28 @@ namespace osu.Game.Beatmaps
}, true);
}
- public void Invalidate(IBeatmapInfo beatmap)
+ ///
+ /// Notify this cache that a beatmap has been invalidated/updated.
+ ///
+ /// The old beatmap model.
+ /// The updated beatmap model.
+ public void Invalidate(IBeatmapInfo oldBeatmap, IBeatmapInfo newBeatmap)
{
- base.Invalidate(lookup => lookup.BeatmapInfo.Equals(beatmap));
+ base.Invalidate(lookup => lookup.BeatmapInfo.Equals(oldBeatmap));
+
+ lock (bindableUpdateLock)
+ {
+ bool trackedBindablesRefreshRequired = false;
+
+ foreach (var bsd in trackedBindables.Where(bsd => bsd.BeatmapInfo.Equals(oldBeatmap)))
+ {
+ bsd.BeatmapInfo = newBeatmap;
+ trackedBindablesRefreshRequired = true;
+ }
+
+ if (trackedBindablesRefreshRequired)
+ Scheduler.AddOnce(updateTrackedBindables);
+ }
}
///
@@ -358,7 +377,7 @@ namespace osu.Game.Beatmaps
private class BindableStarDifficulty : Bindable
{
- public readonly IBeatmapInfo BeatmapInfo;
+ public IBeatmapInfo BeatmapInfo;
public readonly CancellationToken CancellationToken;
public BindableStarDifficulty(IBeatmapInfo beatmapInfo, CancellationToken cancellationToken)
diff --git a/osu.Game/Beatmaps/BeatmapUpdater.cs b/osu.Game/Beatmaps/BeatmapUpdater.cs
index ff23bf1242..72c69393df 100644
--- a/osu.Game/Beatmaps/BeatmapUpdater.cs
+++ b/osu.Game/Beatmaps/BeatmapUpdater.cs
@@ -52,11 +52,11 @@ namespace osu.Game.Beatmaps
foreach (BeatmapInfo beatmap in beatmapSet.Beatmaps)
{
- difficultyCache.Invalidate(beatmap);
-
var working = workingBeatmapCache.GetWorkingBeatmap(beatmap);
- var ruleset = working.BeatmapInfo.Ruleset.CreateInstance();
+ difficultyCache.Invalidate(beatmap, working.BeatmapInfo);
+
+ var ruleset = working.BeatmapInfo.Ruleset.CreateInstance();
var calculator = ruleset.CreateDifficultyCalculator(working);
beatmap.StarRating = calculator.Calculate().StarRating;