From fe6b18d4b66acb22eb26736cdd58f53fcd03421d Mon Sep 17 00:00:00 2001 From: Piranha91 Date: Tue, 16 Jan 2024 01:00:21 -0800 Subject: [PATCH] Fixed null refs blocking compilation in Git --- HappyCRappy/DTOs/LoadOrderBlock.cs | 2 +- HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderBlock.cs | 3 ++- HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderMenu.cs | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/HappyCRappy/DTOs/LoadOrderBlock.cs b/HappyCRappy/DTOs/LoadOrderBlock.cs index 0a82895..b82790b 100644 --- a/HappyCRappy/DTOs/LoadOrderBlock.cs +++ b/HappyCRappy/DTOs/LoadOrderBlock.cs @@ -12,5 +12,5 @@ public class LoadOrderBlock public List Mods { get; set; } = new(); public ModKey? PlaceAfter { get; set; } public ModKey? PlaceBefore { get; set; } - public string Name { get; set; } + public string Name { get; set; } = string.Empty; } diff --git a/HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderBlock.cs b/HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderBlock.cs index 93414d5..ba6a374 100644 --- a/HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderBlock.cs +++ b/HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderBlock.cs @@ -33,6 +33,7 @@ public VM_LoadOrderBlock(VM_LoadOrderStash parentSnapshot, VM_LoadOrderMenu pare canExecute: _ => true, execute: x => { + if (x == null) { return; } Mods.Remove((VM_ModKeyWrapper)x); DeleteIfNecessary(); } @@ -67,7 +68,7 @@ public VM_LoadOrderBlock(VM_LoadOrderStash parentSnapshot, VM_LoadOrderMenu pare private readonly VM_LoadOrderMenu _parentMenu; private readonly VM_LoadOrderStash _parentSnapshot; private readonly VM_ModKeyWrapper.Factory _modWrapperFactory; - public string Name { get; set; } + public string Name { get; set; } = string.Empty; public ObservableCollection Mods { get; set; } = new(); public VM_ModKeyWrapper? PlaceAfter { get; set; } public ObservableCollection AvailablePriorMods { get; set; } = new(); diff --git a/HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderMenu.cs b/HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderMenu.cs index 3a7b2b1..ea20e5f 100644 --- a/HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderMenu.cs +++ b/HappyCRappy/UI/Menus/Load Order Menu/VM_LoadOrderMenu.cs @@ -281,9 +281,11 @@ public VM_ModKeyWrapper(ModKey modKey, Func parentMenu) public void RefreshAvailability() { - if (_parentMenu().SelectedStash != null && - _parentMenu().SelectedStash?.ModChunks != null && - _parentMenu().SelectedStash.ModChunks.Where(x => x.Mods.Select(y => y.ModKey).Contains(ModKey)).Any()) + var parentMenu = _parentMenu(); + if (parentMenu != null && + parentMenu.SelectedStash != null && + parentMenu.SelectedStash?.ModChunks != null && + parentMenu.SelectedStash.ModChunks.Where(x => x.Mods.Select(y => y.ModKey).Contains(ModKey)).Any()) { IsManaged = true; BorderColor = new(Colors.Gray);