0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 13:25:45 +00:00

Try and fix nullref

This commit is contained in:
Evan Husted 2024-12-07 05:21:16 -06:00
parent 290a6ad5de
commit 4ffb8aef12
2 changed files with 7 additions and 9 deletions

View file

@ -1082,11 +1082,10 @@ namespace Ryujinx.UI.App.Common
var currentlySelected = TitleUpdates.Items.FindFirst(it => var currentlySelected = TitleUpdates.Items.FindFirst(it =>
it.TitleUpdate.TitleIdBase == update.TitleIdBase && it.IsSelected); it.TitleUpdate.TitleIdBase == update.TitleIdBase && it.IsSelected);
var shouldSelect = !currentlySelected.HasValue || var shouldSelect = currentlySelected.Check(curr => curr.TitleUpdate.Version < update.Version);
currentlySelected.Value.TitleUpdate.Version < update.Version;
_titleUpdates.AddOrUpdate((update, shouldSelect)); _titleUpdates.AddOrUpdate((update, shouldSelect));
if (currentlySelected.HasValue && shouldSelect) if (currentlySelected.HasValue && shouldSelect)
{ {
_titleUpdates.AddOrUpdate((currentlySelected.Value.TitleUpdate, false)); _titleUpdates.AddOrUpdate((currentlySelected.Value.TitleUpdate, false));
@ -1478,7 +1477,7 @@ namespace Ryujinx.UI.App.Common
if (TryGetTitleUpdatesFromFile(application.Path, out var bundledUpdates)) 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; bool updatesChanged = false;
foreach (var update in bundledUpdates.OrderByDescending(bundled => bundled.Version)) foreach (var update in bundledUpdates.OrderByDescending(bundled => bundled.Version))
@ -1486,11 +1485,10 @@ namespace Ryujinx.UI.App.Common
if (!savedUpdateLookup.Contains(update)) if (!savedUpdateLookup.Contains(update))
{ {
bool shouldSelect = false; bool shouldSelect = false;
if (!selectedUpdate.HasValue || selectedUpdate.Value.Item1.Version < update.Version) if (selectedUpdate.Check(su => su.Update.Version < update.Version))
{ {
shouldSelect = true; shouldSelect = true;
if (selectedUpdate) _titleUpdates.AddOrUpdate((selectedUpdate.Value.Update, false));
_titleUpdates.AddOrUpdate((selectedUpdate.Value.Item1, false));
selectedUpdate = (update, true); selectedUpdate = (update, true);
} }

View file

@ -28,7 +28,7 @@ namespace Ryujinx.UI.Common.Helper
{ {
private static readonly TitleUpdateMetadataJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); 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); var titleUpdatesJsonPath = PathToGameUpdatesJson(applicationIdBase);
@ -77,7 +77,7 @@ namespace Ryujinx.UI.Common.Helper
JsonHelper.SerializeToFile(titleUpdatesJsonPath, titleUpdateWindowData, _serializerContext.TitleUpdateMetadata); 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)>(); var result = new List<(TitleUpdateModel, bool IsSelected)>();