From 4ffb8aef129ac4b0469c862cc595aa97816d4808 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sat, 7 Dec 2024 05:21:16 -0600 Subject: [PATCH] Try and fix nullref --- src/Ryujinx.UI.Common/App/ApplicationLibrary.cs | 12 +++++------- src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs index cc5a63ab8..a750db997 100644 --- a/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.UI.Common/App/ApplicationLibrary.cs @@ -1082,11 +1082,10 @@ namespace Ryujinx.UI.App.Common var currentlySelected = TitleUpdates.Items.FindFirst(it => it.TitleUpdate.TitleIdBase == update.TitleIdBase && it.IsSelected); - var shouldSelect = !currentlySelected.HasValue || - currentlySelected.Value.TitleUpdate.Version < update.Version; + var shouldSelect = currentlySelected.Check(curr => curr.TitleUpdate.Version < update.Version); _titleUpdates.AddOrUpdate((update, shouldSelect)); - + if (currentlySelected.HasValue && shouldSelect) { _titleUpdates.AddOrUpdate((currentlySelected.Value.TitleUpdate, false)); @@ -1478,7 +1477,7 @@ namespace Ryujinx.UI.App.Common if (TryGetTitleUpdatesFromFile(application.Path, out var bundledUpdates)) { - var savedUpdateLookup = savedUpdates.Select(update => update.Item1).ToHashSet(); + var savedUpdateLookup = savedUpdates.Select(update => update.Update).ToHashSet(); bool updatesChanged = false; foreach (var update in bundledUpdates.OrderByDescending(bundled => bundled.Version)) @@ -1486,11 +1485,10 @@ namespace Ryujinx.UI.App.Common if (!savedUpdateLookup.Contains(update)) { bool shouldSelect = false; - if (!selectedUpdate.HasValue || selectedUpdate.Value.Item1.Version < update.Version) + if (selectedUpdate.Check(su => su.Update.Version < update.Version)) { shouldSelect = true; - if (selectedUpdate) - _titleUpdates.AddOrUpdate((selectedUpdate.Value.Item1, false)); + _titleUpdates.AddOrUpdate((selectedUpdate.Value.Update, false)); selectedUpdate = (update, true); } diff --git a/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs b/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs index c6bacfd91..36de8b31a 100644 --- a/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs +++ b/src/Ryujinx.UI.Common/Helper/TitleUpdatesHelper.cs @@ -28,7 +28,7 @@ namespace Ryujinx.UI.Common.Helper { private static readonly TitleUpdateMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); - public static List<(TitleUpdateModel, bool IsSelected)> LoadTitleUpdatesJson(VirtualFileSystem vfs, ulong applicationIdBase) + public static List<(TitleUpdateModel Update, bool IsSelected)> LoadTitleUpdatesJson(VirtualFileSystem vfs, ulong applicationIdBase) { var titleUpdatesJsonPath = PathToGameUpdatesJson(applicationIdBase); @@ -77,7 +77,7 @@ namespace Ryujinx.UI.Common.Helper JsonHelper.SerializeToFile(titleUpdatesJsonPath, titleUpdateWindowData, _serializerContext.TitleUpdateMetadata); } - private static List<(TitleUpdateModel, bool IsSelected)> LoadTitleUpdates(VirtualFileSystem vfs, TitleUpdateMetadata titleUpdateMetadata, ulong applicationIdBase) + private static List<(TitleUpdateModel Update, bool IsSelected)> LoadTitleUpdates(VirtualFileSystem vfs, TitleUpdateMetadata titleUpdateMetadata, ulong applicationIdBase) { var result = new List<(TitleUpdateModel, bool IsSelected)>();