Fix incorrect background being loaded due to async race

If the API login (and thus user set) completed between `load` and
`LoadComplete`, the re-fetch on user change would not yet be hooked up,
causing an incorrect default background to be used instead.

Of note, moving this out of async load doesn't really affect load
performance as the bulk of the load operation is already scheduled and
`LoadComponentAsync`ed anyway
This commit is contained in:
Dean Herbert 2024-05-01 00:05:14 +08:00
parent 93be4b314b
commit ff108416d8
No known key found for this signature in database

View File

@ -56,10 +56,6 @@ namespace osu.Game.Screens.Backgrounds
introSequence = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence);
AddInternal(seasonalBackgroundLoader);
// Load first background asynchronously as part of BDL load.
currentDisplay = RNG.Next(0, background_count);
Next();
}
protected override void LoadComplete()
@ -73,6 +69,9 @@ namespace osu.Game.Screens.Backgrounds
introSequence.ValueChanged += _ => Scheduler.AddOnce(next);
seasonalBackgroundLoader.SeasonalBackgroundChanged += () => Scheduler.AddOnce(next);
currentDisplay = RNG.Next(0, background_count);
Next();
// helper function required for AddOnce usage.
void next() => Next();
}