Fix background unloading/reloading sometimes crashing

This commit is contained in:
smoogipoo
2019-05-07 17:24:05 +09:00
parent 1d2db85866
commit a00e2b18a9
2 changed files with 62 additions and 2 deletions

View File

@ -26,6 +26,11 @@ namespace osu.Game.Beatmaps.Drawables
this.beatmapSetCoverType = beatmapSetCoverType;
}
/// <summary>
/// Delay before the background is unloaded while off-screen.
/// </summary>
protected virtual double UnloadDelay => 10000;
private BeatmapInfo lastModel;
protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Drawable content, double timeBeforeLoad)
@ -34,13 +39,13 @@ namespace osu.Game.Beatmaps.Drawables
{
// If DelayedLoadUnloadWrapper is attempting to RELOAD the same content (Beatmap), that means that it was
// previously UNLOADED and thus its children have been disposed of, so we need to recreate them here.
if (lastModel == Beatmap.Value && Beatmap.Value != null)
if (lastModel == Beatmap.Value)
return CreateDrawable(Beatmap.Value);
// If the model has changed since the previous unload (or if there was no load), then we can safely use the given content
lastModel = Beatmap.Value;
return content;
}, timeBeforeLoad, 10000);
}, timeBeforeLoad, UnloadDelay);
}
protected override Drawable CreateDrawable(BeatmapInfo model)