Merge pull request #10637 from peppy/fix-seasonal-backgrounds-nullref

Fix potential null reference when loading background
This commit is contained in:
Bartłomiej Dach 2020-10-31 17:36:16 +01:00 committed by GitHub
commit 7d090e0d2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 8 deletions

View File

@ -149,18 +149,14 @@ namespace osu.Game.Tests.Visual.Background
=> AddStep($"set seasonal mode to {mode}", () => config.Set(OsuSetting.SeasonalBackgroundMode, mode)); => AddStep($"set seasonal mode to {mode}", () => config.Set(OsuSetting.SeasonalBackgroundMode, mode));
private void createLoader() private void createLoader()
{ => AddStep("create loader", () =>
AddStep("create loader", () =>
{ {
if (backgroundLoader != null) if (backgroundLoader != null)
Remove(backgroundLoader); Remove(backgroundLoader);
LoadComponentAsync(backgroundLoader = new SeasonalBackgroundLoader(), Add); Add(backgroundLoader = new SeasonalBackgroundLoader());
}); });
AddUntilStep("wait for loaded", () => backgroundLoader.IsLoaded);
}
private void loadNextBackground() private void loadNextBackground()
{ {
SeasonalBackground background = null; SeasonalBackground background = null;

View File

@ -15,7 +15,6 @@ using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Graphics.Backgrounds namespace osu.Game.Graphics.Backgrounds
{ {
[LongRunningLoad]
public class SeasonalBackgroundLoader : Component public class SeasonalBackgroundLoader : Component
{ {
/// <summary> /// <summary>

View File

@ -44,6 +44,8 @@ namespace osu.Game.Screens.Backgrounds
mode = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource); mode = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource);
introSequence = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence); introSequence = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence);
AddInternal(seasonalBackgroundLoader);
user.ValueChanged += _ => Next(); user.ValueChanged += _ => Next();
skin.ValueChanged += _ => Next(); skin.ValueChanged += _ => Next();
mode.ValueChanged += _ => Next(); mode.ValueChanged += _ => Next();
@ -53,7 +55,6 @@ namespace osu.Game.Screens.Backgrounds
currentDisplay = RNG.Next(0, background_count); currentDisplay = RNG.Next(0, background_count);
LoadComponentAsync(seasonalBackgroundLoader);
Next(); Next();
} }