Move MusicController binds to LoadComplete for added thread safety

This commit is contained in:
Dean Herbert 2022-09-26 15:42:37 +09:00
parent 1eaaf80b99
commit 4e9b25d8b0

View File

@ -58,12 +58,11 @@ namespace osu.Game.Overlays
[Resolved]
private RealmAccess realm { get; set; }
[BackgroundDependencyLoader]
private void load()
protected override void LoadComplete()
{
// Todo: These binds really shouldn't be here, but are unlikely to cause any issues for now.
// They are placed here for now since some tests rely on setting the beatmap _and_ their hierarchies inside their load(), which runs before the MusicController's load().
beatmap.BindValueChanged(beatmapChanged, true);
base.LoadComplete();
beatmap.BindValueChanged(b => changeBeatmap(b.NewValue), true);
mods.BindValueChanged(_ => ResetTrackAdjustments(), true);
}
@ -263,8 +262,6 @@ namespace osu.Game.Overlays
private IQueryable<BeatmapSetInfo> getBeatmapSets() => realm.Realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending);
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> beatmap) => changeBeatmap(beatmap.NewValue);
private void changeBeatmap(WorkingBeatmap newWorking)
{
// This method can potentially be triggered multiple times as it is eagerly fired in next() / prev() to ensure correct execution order