Add null reference checks.

This commit is contained in:
2022-03-17 00:46:26 +00:00
parent f6245f954d
commit b05dc45d09
18 changed files with 528 additions and 441 deletions

View File

@@ -136,6 +136,9 @@ public sealed class MainWindowViewModel : ViewModelBase
break;
}
if(_assets == null)
return;
_genericHddIcon =
new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-harddisk.png")));
@@ -150,15 +153,18 @@ public sealed class MainWindowViewModel : ViewModelBase
_usbIcon =
new
Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media-usb.png")));
Bitmap(_assets.Open(new
Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media-usb.png")));
_removableIcon =
new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media.png")));
new
Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media.png")));
_sdIcon =
new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-flash-sd-mmc.png")));
_ejectIcon = new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-eject.png")));
_ejectIcon =
new Bitmap(_assets.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-eject.png")));
}
public bool DevicesSupported
@@ -168,7 +174,7 @@ public sealed class MainWindowViewModel : ViewModelBase
}
public bool NativeMenuSupported =>
NativeMenu.GetIsNativeMenuExported((Application.Current.ApplicationLifetime as
NativeMenu.GetIsNativeMenuExported((Application.Current?.ApplicationLifetime as
IClassicDesktopStyleApplicationLifetime)?.MainWindow);
[NotNull]
@@ -480,7 +486,7 @@ public sealed class MainWindowViewModel : ViewModelBase
}
internal void ExecuteExitCommand() =>
(Application.Current.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime)?.Shutdown();
(Application.Current?.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime)?.Shutdown();
void ExecuteConsoleCommand()
{