mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-13 13:37:08 +00:00
misc: chore: Fix possible System.NullReferenceExceptions
This commit is contained in:
parent
05a88ccc94
commit
4efb872d0a
3 changed files with 16 additions and 12 deletions
|
|
@ -1160,7 +1160,7 @@ namespace Ryujinx.UI.App.Common
|
|||
return _ncaIcon;
|
||||
}
|
||||
|
||||
return Path.GetExtension(applicationPath).ToLower() switch
|
||||
return Path.GetExtension(applicationPath)?.ToLower() switch
|
||||
{
|
||||
".nsp" => _nspIcon,
|
||||
".pfs0" => _nspIcon,
|
||||
|
|
@ -1177,7 +1177,7 @@ namespace Ryujinx.UI.App.Common
|
|||
// Look for icon only if applicationPath is not a directory
|
||||
if (!Directory.Exists(applicationPath))
|
||||
{
|
||||
string extension = Path.GetExtension(applicationPath).ToLower();
|
||||
string extension = Path.GetExtension(applicationPath)?.ToLower();
|
||||
|
||||
using FileStream file = new(applicationPath, FileMode.Open, FileAccess.Read);
|
||||
|
||||
|
|
@ -1233,7 +1233,7 @@ namespace Ryujinx.UI.App.Common
|
|||
{
|
||||
using var icon = new UniqueRef<IFile>();
|
||||
|
||||
controlFs.OpenFile(ref icon.Ref, $"/icon_{desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
controlFs?.OpenFile(ref icon.Ref, $"/icon_{desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
using MemoryStream stream = new();
|
||||
|
||||
|
|
@ -1251,7 +1251,7 @@ namespace Ryujinx.UI.App.Common
|
|||
|
||||
using var icon = new UniqueRef<IFile>();
|
||||
|
||||
controlFs.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
controlFs?.OpenFile(ref icon.Ref, entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
|
||||
|
||||
using MemoryStream stream = new();
|
||||
icon.Get.AsStream().CopyTo(stream);
|
||||
|
|
@ -1435,7 +1435,10 @@ namespace Ryujinx.UI.App.Common
|
|||
{
|
||||
return new Nca(_virtualFileSystem.KeySet, ncaStorage);
|
||||
}
|
||||
catch (Exception) { }
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -666,7 +666,7 @@ namespace Ryujinx.Ava
|
|||
|
||||
SystemVersion firmwareVersion = ContentManager.GetCurrentFirmwareVersion();
|
||||
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
if (!SetupValidator.CanStartApplication(ContentManager, ApplicationPath, out UserError userError))
|
||||
{
|
||||
|
|
@ -888,7 +888,7 @@ namespace Ryujinx.Ava
|
|||
{
|
||||
renderer = new VulkanRenderer(
|
||||
Vk.GetApi(),
|
||||
(RendererHost.EmbeddedWindow as EmbeddedWindowVulkan).CreateSurface,
|
||||
((EmbeddedWindowVulkan)RendererHost.EmbeddedWindow).CreateSurface,
|
||||
VulkanHelper.GetRequiredInstanceExtensions,
|
||||
ConfigurationState.Instance.Graphics.PreferredGpu.Value);
|
||||
}
|
||||
|
|
@ -1053,7 +1053,7 @@ namespace Ryujinx.Ava
|
|||
Width = (int)RendererHost.Bounds.Width;
|
||||
Height = (int)RendererHost.Bounds.Height;
|
||||
|
||||
_renderer.Window.SetSize((int)(Width * _topLevel.RenderScaling), (int)(Height * _topLevel.RenderScaling));
|
||||
_renderer?.Window?.SetSize((int)(Width * _topLevel.RenderScaling), (int)(Height * _topLevel.RenderScaling));
|
||||
|
||||
_chrono.Start();
|
||||
|
||||
|
|
@ -1296,7 +1296,7 @@ namespace Ryujinx.Ava
|
|||
_viewModel.Volume = Device.GetVolume();
|
||||
break;
|
||||
case KeyboardHotkeyState.None:
|
||||
(_keyboardInterface as AvaloniaKeyboard).Clear();
|
||||
(_keyboardInterface as AvaloniaKeyboard)?.Clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1315,7 +1315,7 @@ namespace Ryujinx.Ava
|
|||
|
||||
if (_viewModel.IsActive && !ConfigurationState.Instance.Hid.EnableMouse.Value)
|
||||
{
|
||||
hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as AvaloniaMouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
|
||||
hasTouch = TouchScreenManager.Update(true, ((AvaloniaMouseDriver)_inputManager.MouseDriver).IsButtonPressed(MouseButton.Button1), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToFloat());
|
||||
}
|
||||
|
||||
if (!hasTouch)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using Ryujinx.Ava.UI.Helpers;
|
|||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.UI.App.Common;
|
||||
using Ryujinx.UI.Common.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
|
@ -264,7 +265,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
switch (_viewModel.SortingField)
|
||||
{
|
||||
case SortField.Name:
|
||||
result = x.Name.CompareTo(y.Name);
|
||||
result = String.Compare(x?.Name, y?.Name, StringComparison.Ordinal);
|
||||
break;
|
||||
case SortField.Saved:
|
||||
result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB);
|
||||
|
|
@ -275,7 +276,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
result = -result;
|
||||
|
||||
if (result == 0)
|
||||
result = x.Path.CompareTo(y.Path);
|
||||
result = String.Compare(x?.Path, y?.Path, StringComparison.Ordinal);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue