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

Apply more correct fix for double-playing menu track

This commit is contained in:
Dean Herbert 2023-06-20 18:35:51 +09:00
parent 0a81170bca
commit 2e02b4a85b
2 changed files with 4 additions and 9 deletions

View File

@ -316,6 +316,8 @@ namespace osu.Game.Overlays
var queuedTrack = getQueuedTrack();
var lastTrack = CurrentTrack;
lastTrack.Completed -= onTrackCompleted;
CurrentTrack = queuedTrack;
// At this point we may potentially be in an async context from tests. This is extremely dangerous but we have to make do for now.
@ -344,16 +346,12 @@ namespace osu.Game.Overlays
// Important to keep this in its own method to avoid inadvertently capturing unnecessary variables in the callback.
// Can lead to leaks.
var queuedTrack = new DrawableTrack(current.LoadTrack());
queuedTrack.Completed += () => onTrackCompleted(current);
queuedTrack.Completed += onTrackCompleted;
return queuedTrack;
}
private void onTrackCompleted(WorkingBeatmap workingBeatmap)
private void onTrackCompleted()
{
// the source of track completion is the audio thread, so the beatmap may have changed before firing.
if (current != workingBeatmap)
return;
if (!CurrentTrack.Looping && !beatmap.Disabled)
NextTrack();
}

View File

@ -813,9 +813,6 @@ namespace osu.Game.Screens.Select
if (!ControlGlobalMusic)
return;
if (Beatmap.Value is DummyWorkingBeatmap)
return;
ITrack track = music.CurrentTrack;
bool isNewTrack = !lastTrack.TryGetTarget(out var last) || last != track;