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

Merge pull request #10840 from bdach/resolved-as-null-checks

Add null checks to unguarded resolved-as-possibly-null fields
This commit is contained in:
Dean Herbert 2020-11-15 13:15:32 +09:00 committed by GitHub
commit 7156682efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 26 additions and 15 deletions

View File

@ -144,9 +144,9 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
if (selected) if (selected)
{ {
selectionBox.Show(); selectionBox.Show();
if (editor) if (editor && editorInfo != null)
editorInfo.Selected.Value = Match; editorInfo.Selected.Value = Match;
else else if (ladderInfo != null)
ladderInfo.CurrentMatch.Value = Match; ladderInfo.CurrentMatch.Value = Match;
} }
else else

View File

@ -46,12 +46,15 @@ namespace osu.Game.Online
{ {
if (modelInfo.NewValue == null) if (modelInfo.NewValue == null)
attachDownload(null); attachDownload(null);
else if (manager.IsAvailableLocally(modelInfo.NewValue)) else if (manager?.IsAvailableLocally(modelInfo.NewValue) == true)
State.Value = DownloadState.LocallyAvailable; State.Value = DownloadState.LocallyAvailable;
else else
attachDownload(manager.GetExistingDownload(modelInfo.NewValue)); attachDownload(manager?.GetExistingDownload(modelInfo.NewValue));
}, true); }, true);
if (manager == null)
return;
managerDownloadBegan = manager.DownloadBegan.GetBoundCopy(); managerDownloadBegan = manager.DownloadBegan.GetBoundCopy();
managerDownloadBegan.BindValueChanged(downloadBegan); managerDownloadBegan.BindValueChanged(downloadBegan);
managerDownloadFailed = manager.DownloadFailed.GetBoundCopy(); managerDownloadFailed = manager.DownloadFailed.GetBoundCopy();

View File

@ -248,7 +248,9 @@ namespace osu.Game.Online.Leaderboards
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
if (api != null)
apiState.BindTo(api.State); apiState.BindTo(api.State);
apiState.BindValueChanged(onlineStateChanged, true); apiState.BindValueChanged(onlineStateChanged, true);
} }
@ -303,7 +305,7 @@ namespace osu.Game.Online.Leaderboards
PlaceholderState = PlaceholderState.NetworkFailure; PlaceholderState = PlaceholderState.NetworkFailure;
}); });
api.Queue(getScoresRequest); api?.Queue(getScoresRequest);
}); });
} }

View File

@ -30,7 +30,7 @@ namespace osu.Game.Overlays.AccountCreation
public override void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
if (string.IsNullOrEmpty(api.ProvidedUsername)) if (string.IsNullOrEmpty(api?.ProvidedUsername))
{ {
this.FadeOut(); this.FadeOut();
this.Push(new ScreenEntry()); this.Push(new ScreenEntry());
@ -43,7 +43,7 @@ namespace osu.Game.Overlays.AccountCreation
[BackgroundDependencyLoader(true)] [BackgroundDependencyLoader(true)]
private void load(OsuColour colours, OsuGame game, TextureStore textures) private void load(OsuColour colours, OsuGame game, TextureStore textures)
{ {
if (string.IsNullOrEmpty(api.ProvidedUsername)) if (string.IsNullOrEmpty(api?.ProvidedUsername))
return; return;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]

View File

@ -217,7 +217,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
private void performLogin() private void performLogin()
{ {
if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text)) if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
api.Login(username.Text, password.Text); api?.Login(username.Text, password.Text);
else else
shakeSignIn.Shake(); shakeSignIn.Shake();
} }

View File

@ -76,7 +76,7 @@ namespace osu.Game
// a dialog may be blocking the execution for now. // a dialog may be blocking the execution for now.
if (checkForDialog(current)) return; if (checkForDialog(current)) return;
game.CloseAllOverlays(false); game?.CloseAllOverlays(false);
// we may already be at the target screen type. // we may already be at the target screen type.
if (validScreens.Contains(getCurrentScreen().GetType()) && !beatmap.Disabled) if (validScreens.Contains(getCurrentScreen().GetType()) && !beatmap.Disabled)

View File

@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.UI
{ {
Debug.Assert(!drawableMap.ContainsKey(entry)); Debug.Assert(!drawableMap.ContainsKey(entry));
var drawable = pooledObjectProvider.GetPooledDrawableRepresentation(entry.HitObject); var drawable = pooledObjectProvider?.GetPooledDrawableRepresentation(entry.HitObject);
if (drawable == null) if (drawable == null)
throw new InvalidOperationException($"A drawable representation could not be retrieved for hitobject type: {entry.HitObject.GetType().ReadableName()}."); throw new InvalidOperationException($"A drawable representation could not be retrieved for hitobject type: {entry.HitObject.GetType().ReadableName()}.");

View File

@ -457,6 +457,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (movementBlueprint == null) if (movementBlueprint == null)
return false; return false;
if (snapProvider == null)
return true;
Debug.Assert(movementBlueprintOriginalPosition != null); Debug.Assert(movementBlueprintOriginalPosition != null);
HitObject draggedObject = movementBlueprint.HitObject; HitObject draggedObject = movementBlueprint.HitObject;

View File

@ -110,7 +110,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary> /// </summary>
protected virtual void OnOperationBegan() protected virtual void OnOperationBegan()
{ {
ChangeHandler.BeginChange(); ChangeHandler?.BeginChange();
} }
/// <summary> /// <summary>
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary> /// </summary>
protected virtual void OnOperationEnded() protected virtual void OnOperationEnded()
{ {
ChangeHandler.EndChange(); ChangeHandler?.EndChange();
} }
#region User Input Handling #region User Input Handling

View File

@ -96,7 +96,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
if (lastDragEvent != null) if (lastDragEvent != null)
OnDrag(lastDragEvent); OnDrag(lastDragEvent);
if (Composer != null) if (Composer != null && timeline != null)
{ {
Composer.Playfield.PastLifetimeExtension = timeline.VisibleRange / 2; Composer.Playfield.PastLifetimeExtension = timeline.VisibleRange / 2;
Composer.Playfield.FutureLifetimeExtension = timeline.VisibleRange / 2; Composer.Playfield.FutureLifetimeExtension = timeline.VisibleRange / 2;

View File

@ -128,7 +128,7 @@ namespace osu.Game.Screens.Edit.Timing
controlPointGroups.BindCollectionChanged((sender, args) => controlPointGroups.BindCollectionChanged((sender, args) =>
{ {
table.ControlGroups = controlPointGroups; table.ControlGroups = controlPointGroups;
changeHandler.SaveState(); changeHandler?.SaveState();
}, true); }, true);
} }

View File

@ -59,6 +59,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
{ {
scheduledFilterUpdate?.Cancel(); scheduledFilterUpdate?.Cancel();
if (filter == null)
return;
filter.Value = new FilterCriteria filter.Value = new FilterCriteria
{ {
SearchString = Search.Current.Value ?? string.Empty, SearchString = Search.Current.Value ?? string.Empty,