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

Merge pull request #14341 from smoogipoo/fix-preview-track-crash

Fix crashes from preview tracks
This commit is contained in:
Dean Herbert 2021-08-16 22:21:52 +09:00 committed by GitHub
commit 7b74301fa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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