Merge pull request #1193 from peppy/beatmap-background-disposal-fix

Fix beatmap background being disposed too early
This commit is contained in:
Dean Herbert
2017-08-25 14:50:34 +09:00
committed by GitHub
2 changed files with 8 additions and 12 deletions

View File

@ -152,14 +152,10 @@ namespace osu.Game
Beatmap.ValueChanged += b => Beatmap.ValueChanged += b =>
{ {
// compare to last baetmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo) // compare to last beatmap as sometimes the two may share a track representation (optimisation, see WorkingBeatmap.TransferTo)
if (lastBeatmap?.Track != b.Track) if (lastBeatmap?.Track != b.Track)
{ {
// this disposal is done to stop the audio track. lastBeatmap?.Track?.Dispose();
// it may not be exactly what we want for cases beatmaps are reused, as it will
// trigger a fresh load of contained resources.
lastBeatmap?.Dispose();
Audio.Track.AddItem(b.Track); Audio.Track.AddItem(b.Track);
} }

View File

@ -348,23 +348,23 @@ namespace osu.Game.Overlays
playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap) playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap)
{ {
OnLoadComplete = d => OnLoadComplete = newBackground =>
{ {
switch (direction) switch (direction)
{ {
case TransformDirection.Next: case TransformDirection.Next:
d.Position = new Vector2(400, 0); newBackground.Position = new Vector2(400, 0);
d.MoveToX(0, 500, Easing.OutCubic); newBackground.MoveToX(0, 500, Easing.OutCubic);
currentBackground.MoveToX(-400, 500, Easing.OutCubic); currentBackground.MoveToX(-400, 500, Easing.OutCubic);
break; break;
case TransformDirection.Prev: case TransformDirection.Prev:
d.Position = new Vector2(-400, 0); newBackground.Position = new Vector2(-400, 0);
d.MoveToX(0, 500, Easing.OutCubic); newBackground.MoveToX(0, 500, Easing.OutCubic);
currentBackground.MoveToX(400, 500, Easing.OutCubic); currentBackground.MoveToX(400, 500, Easing.OutCubic);
break; break;
} }
currentBackground.Expire(); currentBackground.Expire();
currentBackground = d; currentBackground = newBackground;
} }
}) })
{ {