mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-09-29 15:27:53 +02:00
misc: chore: Fix numerous NullReferenceExceptions, InvalidOperationExceptions
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
return app.Favorite ? -1 : 1;
|
||||
}
|
||||
|
||||
throw new InvalidCastException($"Cannot cast {o.GetType()} to {nameof(AppListFavoriteComparable)}");
|
||||
throw new InvalidCastException($"Cannot cast {o?.GetType()} to {nameof(AppListFavoriteComparable)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
_applicationData = applicationData;
|
||||
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
_storageProvider = desktop.MainWindow.StorageProvider;
|
||||
_storageProvider = desktop.MainWindow?.StorageProvider;
|
||||
}
|
||||
|
||||
LoadDownloadableContents();
|
||||
|
||||
@@ -254,10 +254,13 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
|
||||
AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner);
|
||||
|
||||
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
||||
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
|
||||
if (_mainWindow != null)
|
||||
{
|
||||
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
||||
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
|
||||
|
||||
_mainWindow.ViewModel.AppHost?.NpadManager.BlockInputUpdates();
|
||||
_mainWindow.ViewModel.AppHost?.NpadManager.BlockInputUpdates();
|
||||
}
|
||||
|
||||
_isLoaded = false;
|
||||
|
||||
@@ -783,11 +786,14 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||
config = (ConfigViewModel as ControllerInputViewModel)?.Config.GetConfig();
|
||||
}
|
||||
|
||||
config.ControllerType = Controllers[_controller].Type;
|
||||
if (config != null)
|
||||
{
|
||||
config.ControllerType = Controllers[_controller].Type;
|
||||
|
||||
string jsonString = JsonHelper.Serialize(config, _serializerContext.InputConfig);
|
||||
string jsonString = JsonHelper.Serialize(config, _serializerContext.InputConfig);
|
||||
|
||||
await File.WriteAllTextAsync(path, jsonString);
|
||||
await File.WriteAllTextAsync(path, jsonString);
|
||||
}
|
||||
|
||||
LoadProfiles();
|
||||
}
|
||||
|
||||
@@ -1332,7 +1332,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
}
|
||||
catch (MissingKeyException ex)
|
||||
{
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
Logger.Error?.Print(LogClass.Application, ex.ToString());
|
||||
|
||||
@@ -1553,7 +1553,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
Application.Current.Styles.TryGetResource(args.VSyncMode,
|
||||
Application.Current!.Styles.TryGetResource(args.VSyncMode,
|
||||
Application.Current.ActualThemeVariant,
|
||||
out object color);
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
foreach (var dir in directories)
|
||||
{
|
||||
string dirToCreate = dir.Replace(directory.Parent.ToString(), destinationDir);
|
||||
string dirToCreate = dir.Replace(directory.Parent?.ToString() ?? string.Empty, destinationDir);
|
||||
|
||||
// Mod already exists
|
||||
if (Directory.Exists(dirToCreate))
|
||||
@@ -302,7 +302,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
File.Copy(file, file.Replace(directory.Parent.ToString(), destinationDir), true);
|
||||
File.Copy(file, file.Replace(directory.Parent?.ToString() ?? string.Empty, destinationDir), true);
|
||||
}
|
||||
|
||||
LoadMods(_applicationId, _installedDlcIds);
|
||||
|
||||
@@ -75,9 +75,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
ApplicationData = applicationData;
|
||||
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
StorageProvider = desktop.MainWindow.StorageProvider;
|
||||
StorageProvider = desktop.MainWindow?.StorageProvider;
|
||||
}
|
||||
|
||||
LoadUpdates();
|
||||
|
||||
@@ -268,7 +268,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
result = String.Compare(x?.Name, y?.Name, StringComparison.Ordinal);
|
||||
break;
|
||||
case SortField.Saved:
|
||||
result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB);
|
||||
if (x != null && y != null)
|
||||
{
|
||||
result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user