1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-28 07:32:55 +08:00

Fix MusicController holding references to beatmaps while inacti… (#5158)

Fix MusicController holding references to beatmaps while inactive
This commit is contained in:
Dean Herbert 2019-06-26 19:30:16 +09:00 committed by GitHub
commit 6812eccdd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -259,6 +259,12 @@ namespace osu.Game.Overlays
{ {
base.Update(); base.Update();
if (pendingBeatmapSwitch != null)
{
pendingBeatmapSwitch();
pendingBeatmapSwitch = null;
}
var track = current?.TrackLoaded ?? false ? current.Track : null; var track = current?.TrackLoaded ?? false ? current.Track : null;
if (track?.IsDummyDevice == false) if (track?.IsDummyDevice == false)
@ -368,15 +374,12 @@ namespace osu.Game.Overlays
mod.ApplyToClock(track); mod.ApplyToClock(track);
} }
private ScheduledDelegate pendingBeatmapSwitch; private Action pendingBeatmapSwitch;
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction) private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
{ {
//we might be off-screen when this update comes in. // avoid using scheduler as our scheduler may not be run for a long time, holding references to beatmaps.
//rather than Scheduling, manually handle this to avoid possible memory contention. pendingBeatmapSwitch = delegate
pendingBeatmapSwitch?.Cancel();
pendingBeatmapSwitch = Schedule(delegate
{ {
// todo: this can likely be replaced with WorkingBeatmap.GetBeatmapAsync() // todo: this can likely be replaced with WorkingBeatmap.GetBeatmapAsync()
Task.Run(() => Task.Run(() =>
@ -416,7 +419,7 @@ namespace osu.Game.Overlays
playerContainer.Add(newBackground); playerContainer.Add(newBackground);
}); });
}); };
} }
protected override void PopIn() protected override void PopIn()