mirror of https://github.com/ppy/osu
Improve beatmap track disposal logic
- [ ] Depends on https://github.com/ppy/osu-framework/pull/1035
This commit is contained in:
parent
2f1af3812d
commit
5b9d906ad5
|
@ -109,10 +109,17 @@ public void TransferTo(WorkingBeatmap other)
|
|||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
track?.Dispose();
|
||||
track = null;
|
||||
background?.Dispose();
|
||||
background = null;
|
||||
}
|
||||
|
||||
public void DisposeTrack()
|
||||
{
|
||||
lock (trackLock)
|
||||
{
|
||||
track?.Dispose();
|
||||
track = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,10 +152,19 @@ private void load()
|
|||
|
||||
Beatmap.ValueChanged += b =>
|
||||
{
|
||||
var trackLoaded = lastBeatmap?.TrackLoaded ?? false;
|
||||
|
||||
// compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
|
||||
if (lastBeatmap?.Track != b.Track)
|
||||
if (!trackLoaded || lastBeatmap?.Track != b.Track)
|
||||
{
|
||||
lastBeatmap?.Track?.Dispose();
|
||||
if (trackLoaded)
|
||||
{
|
||||
Debug.Assert(lastBeatmap != null);
|
||||
Debug.Assert(lastBeatmap.Track != null);
|
||||
|
||||
lastBeatmap.DisposeTrack();
|
||||
}
|
||||
|
||||
Audio.Track.AddItem(b.Track);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue