1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 16:03:01 +08:00

Fix preview track crashes

This commit is contained in:
smoogipoo 2021-08-16 18:46:44 +09:00
parent 6dfab4d431
commit db1a0ebb55

View File

@ -139,19 +139,24 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
LoadComponentAsync(Preview = previewTrackManager.Get(beatmapSet), preview => LoadComponentAsync(Preview = previewTrackManager.Get(beatmapSet), preview =>
{ {
// beatmapset may have changed. // Make sure that we schedule to after the next audio frame to fix crashes in single-threaded execution.
if (Preview != preview) // See: https://github.com/ppy/osu-framework/issues/4692
return; Schedule(() =>
{
// beatmapset may have changed.
if (Preview != preview)
return;
AddInternal(preview); AddInternal(preview);
loading = false; loading = false;
// make sure that the update of value of Playing (and the ensuing value change callbacks) // make sure that the update of value of Playing (and the ensuing value change callbacks)
// are marshaled back to the update thread. // are marshaled back to the update thread.
preview.Stopped += () => Schedule(() => playing.Value = false); preview.Stopped += () => Schedule(() => playing.Value = false);
// user may have changed their mind. // user may have changed their mind.
if (playing.Value) if (playing.Value)
attemptStart(); attemptStart();
});
}); });
} }
else else