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

Dispose previous waveform on track reload

This commit is contained in:
Salman Ahmed 2022-12-23 00:35:59 +03:00
parent 20370bd5ae
commit 30de9ba795
2 changed files with 7 additions and 9 deletions

View File

@ -46,10 +46,11 @@ namespace osu.Game.Beatmaps
private readonly object beatmapFetchLock = new object();
private Waveform waveform;
private readonly Lazy<Storyboard> storyboard;
private readonly Lazy<ISkin> skin;
private Track track; // track is not Lazy as we allow transferring and loading multiple times.
private Waveform waveform; // waveform is also not Lazy as the track may change.
protected WorkingBeatmap(BeatmapInfo beatmapInfo, AudioManager audioManager)
{
@ -107,10 +108,12 @@ namespace osu.Game.Beatmaps
public Track LoadTrack()
{
// track could be changed, clearing waveform cache
track = GetBeatmapTrack() ?? GetVirtualTrack(1000);
// the track may have changed, recycle the current waveform.
waveform?.Dispose();
waveform = null;
track = GetBeatmapTrack() ?? GetVirtualTrack(1000);
return track;
}

View File

@ -141,12 +141,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
waveformOpacity = config.GetBindable<float>(OsuSetting.EditorWaveformOpacity);
track.BindTo(editorClock.Track);
track.BindValueChanged(_ =>
{
waveform.Waveform = beatmap.Value.Waveform;
}, true);
waveform.Waveform = beatmap.Value.Waveform;
track.BindValueChanged(_ => waveform.Waveform = beatmap.Value.Waveform, true);
Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
}