mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:02:55 +08:00
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 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
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 @@ namespace osu.Game
|
||||
|
||||
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
Block a user