mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 12:53:11 +08:00
Fix invalid IsLoaded
check
Would fail when `availableMods` would be changed from a different thread while the columns aren't loaded.
This commit is contained in:
parent
528342411e
commit
0c2b4a6c0b
@ -250,9 +250,8 @@ namespace osu.Game.Overlays.Mods
|
||||
private void load(OsuGameBase game, OverlayColourProvider colourProvider, OsuColour colours)
|
||||
{
|
||||
availableMods.BindTo(game.AvailableMods);
|
||||
// this `BindValueChanged` callback is intentionally here, to ensure that local available mods are constructed as early as possible.
|
||||
// this is needed to make sure no external changes to mods are dropped while mod panels are asynchronously loading.
|
||||
availableMods.BindValueChanged(_ => updateLocalAvailableMods(), true);
|
||||
updateLocalAvailableMods(asyncLoadContent: false);
|
||||
availableMods.BindValueChanged(_ => updateLocalAvailableMods(asyncLoadContent: true));
|
||||
|
||||
headerBackground.Colour = accentColour = colours.ForModType(ModType);
|
||||
|
||||
@ -279,7 +278,7 @@ namespace osu.Game.Overlays.Mods
|
||||
toggleAllCheckbox.LabelText = toggleAllCheckbox.Current.Value ? CommonStrings.DeselectAll : CommonStrings.SelectAll;
|
||||
}
|
||||
|
||||
private void updateLocalAvailableMods()
|
||||
private void updateLocalAvailableMods(bool asyncLoadContent)
|
||||
{
|
||||
var newMods = ModUtils.FlattenMods(availableMods.Value.GetValueOrDefault(ModType) ?? Array.Empty<Mod>())
|
||||
.Select(m => m.DeepClone())
|
||||
@ -290,11 +289,10 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
localAvailableMods = newMods;
|
||||
|
||||
if (!IsLoaded)
|
||||
// if we're coming from BDL, perform the first load synchronously to make sure everything is in place as early as possible.
|
||||
onPanelsLoaded(createPanels());
|
||||
else
|
||||
if (asyncLoadContent)
|
||||
asyncLoadPanels();
|
||||
else
|
||||
onPanelsLoaded(createPanels());
|
||||
}
|
||||
|
||||
private CancellationTokenSource? cancellationTokenSource;
|
||||
|
Loading…
Reference in New Issue
Block a user