1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Make dependency nullable to allow for safer disposal unbinding

This commit is contained in:
Dean Herbert 2022-05-19 13:49:52 +09:00
parent 0cee90e156
commit a443200d0d
2 changed files with 5 additions and 5 deletions

View File

@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
[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]

View File

@ -192,14 +192,14 @@ namespace osu.Game.Overlays.FirstRunSetup
private readonly Bindable<DirectoryInfo> currentDirectory = new Bindable<DirectoryInfo>();
[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);