From a443200d0d25c54a0e28a0691b9ada5a9bd2bab1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 May 2022 13:49:52 +0900 Subject: [PATCH] Make dependency nullable to allow for safer disposal unbinding --- .../Skinning/Legacy/LegacyMainCirclePiece.cs | 2 +- osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyMainCirclePiece.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyMainCirclePiece.cs index 391147648f..dd6226e19b 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyMainCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyMainCirclePiece.cs @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy private readonly Bindable accentColour = new Bindable(); private readonly IBindable indexInCurrentCombo = new Bindable(); - [Resolved(canBeNull: true)] + [Resolved(canBeNull: true)] // Can't really be null but required to handle potential of disposal before DI completes. private DrawableHitObject? drawableObject { get; set; } [Resolved] diff --git a/osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs b/osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs index cf8abf0a76..62b517d982 100644 --- a/osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs +++ b/osu.Game/Overlays/FirstRunSetup/ScreenImportFromStable.cs @@ -192,14 +192,14 @@ namespace osu.Game.Overlays.FirstRunSetup private readonly Bindable currentDirectory = new Bindable(); - [Resolved] - private OsuGameBase game { get; set; } = null!; + [Resolved(canBeNull: true)] // Can't really be null but required to handle potential of disposal before DI completes. + private OsuGameBase? game { get; set; } protected override void LoadComplete() { base.LoadComplete(); - game.RegisterImportHandler(this); + game?.RegisterImportHandler(this); currentDirectory.BindValueChanged(onDirectorySelected); @@ -242,7 +242,7 @@ namespace osu.Game.Overlays.FirstRunSetup protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); - game.UnregisterImportHandler(this); + game?.UnregisterImportHandler(this); } public override Popover GetPopover() => new DirectoryChooserPopover(currentDirectory);