mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-16 13:37:03 +00:00
misc: chore: Fix possible System.NullReferenceExceptions
This commit is contained in:
parent
19013d360a
commit
3c644a712d
8 changed files with 26 additions and 27 deletions
|
|
@ -39,7 +39,7 @@ namespace Ryujinx.HLE.Generators
|
|||
var type = constructors.Where(x => x.ParameterList.Parameters.Count == 2).FirstOrDefault().ParameterList.Parameters[1].Type;
|
||||
var model = context.Compilation.GetSemanticModel(type.SyntaxTree);
|
||||
var typeSymbol = model.GetSymbolInfo(type).Symbol as INamedTypeSymbol;
|
||||
var fullName = typeSymbol.ToString();
|
||||
var fullName = typeSymbol?.ToString();
|
||||
generator.EnterScope("if (parameter != null)");
|
||||
generator.AppendLine($"return new {GetFullName(className, context)}(context, ({fullName})parameter);");
|
||||
generator.LeaveScope();
|
||||
|
|
@ -67,7 +67,7 @@ namespace Ryujinx.HLE.Generators
|
|||
{
|
||||
var typeSymbol = context.Compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetDeclaredSymbol(syntaxNode);
|
||||
|
||||
return typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
|
||||
return typeSymbol?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
|
||||
}
|
||||
|
||||
public void Initialize(GeneratorInitializationContext context)
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
|||
{
|
||||
targetPrevAddress = InvalidAddress;
|
||||
}
|
||||
node = node.Previous;
|
||||
node = node?.Previous;
|
||||
_tree.Remove(prevAddress);
|
||||
_list.Remove(_dictionary[prevAddress]);
|
||||
_dictionary.Remove(prevAddress);
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ namespace Ryujinx.Headless.SDL2
|
|||
// Get screen touch position
|
||||
if (!_enableMouse)
|
||||
{
|
||||
hasTouch = TouchScreenManager.Update(true, (_inputManager.MouseDriver as SDL2MouseDriver).IsButtonPressed(MouseButton.Button1), _aspectRatio.ToFloat());
|
||||
hasTouch = TouchScreenManager.Update(true, ((SDL2MouseDriver)_inputManager.MouseDriver).IsButtonPressed(MouseButton.Button1), _aspectRatio.ToFloat());
|
||||
}
|
||||
|
||||
if (!hasTouch)
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ namespace Ryujinx.Horizon.Kernel.Generators
|
|||
{
|
||||
string name = methodParameter.Identifier.Text;
|
||||
string argName = GetPrefixedArgName(name);
|
||||
string typeName = methodParameter.Type.ToString();
|
||||
string typeName = methodParameter.Type?.ToString();
|
||||
string canonicalTypeName = GetCanonicalTypeName(compilation, methodParameter.Type);
|
||||
|
||||
if (methodParameter.Modifiers.Any(SyntaxKind.OutKeyword))
|
||||
|
|
@ -329,7 +329,7 @@ namespace Ryujinx.Horizon.Kernel.Generators
|
|||
{
|
||||
string name = methodParameter.Identifier.Text;
|
||||
string argName = GetPrefixedArgName(name);
|
||||
string typeName = methodParameter.Type.ToString();
|
||||
string typeName = methodParameter.Type?.ToString();
|
||||
string canonicalTypeName = GetCanonicalTypeName(compilation, methodParameter.Type);
|
||||
|
||||
if (methodParameter.Modifiers.Any(SyntaxKind.OutKeyword))
|
||||
|
|
@ -415,9 +415,9 @@ namespace Ryujinx.Horizon.Kernel.Generators
|
|||
private static string GetCanonicalTypeName(Compilation compilation, SyntaxNode syntaxNode)
|
||||
{
|
||||
TypeInfo typeInfo = compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetTypeInfo(syntaxNode);
|
||||
if (typeInfo.Type.ContainingNamespace == null)
|
||||
if (typeInfo.Type?.ContainingNamespace == null)
|
||||
{
|
||||
return typeInfo.Type.Name;
|
||||
return typeInfo.Type?.Name;
|
||||
}
|
||||
|
||||
return $"{typeInfo.Type.ContainingNamespace.ToDisplayString()}.{typeInfo.Type.Name}";
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
private PlayerIndex _playerId;
|
||||
private PlayerIndex _playerIdChoose;
|
||||
private int _controller;
|
||||
private int _controllerNumber;
|
||||
private string _controllerImage;
|
||||
private int _device;
|
||||
private object _configViewModel;
|
||||
|
|
@ -247,8 +246,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
if (Program.PreviewerDetached)
|
||||
{
|
||||
_mainWindow =
|
||||
(MainWindow)((IClassicDesktopStyleApplicationLifetime)Application.Current
|
||||
.ApplicationLifetime).MainWindow;
|
||||
(MainWindow)((IClassicDesktopStyleApplicationLifetime)Application.Current?
|
||||
.ApplicationLifetime)?.MainWindow;
|
||||
|
||||
AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner);
|
||||
|
||||
|
|
@ -519,7 +518,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
{
|
||||
ProfilesList.Clear();
|
||||
|
||||
string basePath = GetProfileBasePath();
|
||||
string basePath = GetProfileBasePath() ?? string.Empty;
|
||||
|
||||
if (!Directory.Exists(basePath))
|
||||
{
|
||||
|
|
@ -773,11 +772,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
|
||||
if (IsKeyboard)
|
||||
{
|
||||
config = (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig();
|
||||
config = (ConfigViewModel as KeyboardInputViewModel)?.Config.GetConfig();
|
||||
}
|
||||
else if (IsController)
|
||||
{
|
||||
config = (ConfigViewModel as ControllerInputViewModel).Config.GetConfig();
|
||||
config = (ConfigViewModel as ControllerInputViewModel)?.Config.GetConfig();
|
||||
}
|
||||
|
||||
config.ControllerType = Controllers[_controller].Type;
|
||||
|
|
@ -842,18 +841,18 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
|||
|
||||
if (device.Type == DeviceType.Keyboard)
|
||||
{
|
||||
var inputConfig = (ConfigViewModel as KeyboardInputViewModel).Config;
|
||||
var inputConfig = ((KeyboardInputViewModel)ConfigViewModel).Config;
|
||||
inputConfig.Id = device.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
var inputConfig = (ConfigViewModel as ControllerInputViewModel).Config;
|
||||
var inputConfig = ((ControllerInputViewModel)ConfigViewModel).Config;
|
||||
inputConfig.Id = device.Id.Split(" ")[0];
|
||||
}
|
||||
|
||||
var config = !IsController
|
||||
? (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig()
|
||||
: (ConfigViewModel as ControllerInputViewModel).Config.GetConfig();
|
||||
? ((KeyboardInputViewModel)ConfigViewModel).Config.GetConfig()
|
||||
: ((ControllerInputViewModel)ConfigViewModel).Config.GetConfig();
|
||||
config.ControllerType = Controllers[_controller].Type;
|
||||
config.PlayerIndex = _playerId;
|
||||
|
||||
|
|
|
|||
|
|
@ -2251,7 +2251,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
switch (operationOutcome)
|
||||
{
|
||||
case XCIFileTrimmer.OperationOutcome.Successful:
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
if (desktop.MainWindow is MainWindow mainWindow)
|
||||
mainWindow.LoadApplications();
|
||||
|
|
|
|||
|
|
@ -93,9 +93,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
|
||||
_modJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationId.ToString("x16"), "mods.json");
|
||||
|
||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
_storageProvider = desktop.MainWindow.StorageProvider;
|
||||
_storageProvider = desktop.MainWindow?.StorageProvider;
|
||||
}
|
||||
|
||||
LoadMods(applicationId, _installedDlcIds);
|
||||
|
|
@ -117,8 +117,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
|
||||
foreach (var mod in modCache.RomfsDirs)
|
||||
{
|
||||
var modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent.FullName))
|
||||
var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent?.FullName))
|
||||
{
|
||||
Mods.Add(modModel);
|
||||
}
|
||||
|
|
@ -131,8 +131,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
|
||||
foreach (var mod in modCache.ExefsDirs)
|
||||
{
|
||||
var modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent.FullName))
|
||||
var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||
if (Mods.All(x => x.Path != mod.Path.Parent?.FullName))
|
||||
{
|
||||
Mods.Add(modModel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ namespace Ryujinx.Ava.UI.Views.Main
|
|||
|
||||
private async void StopEmulation_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Window.ViewModel.AppHost?.ShowExitPrompt();
|
||||
await Window.ViewModel.AppHost.ShowExitPrompt();
|
||||
}
|
||||
|
||||
private void PauseEmulation_Click(object sender, RoutedEventArgs e)
|
||||
|
|
@ -211,7 +211,7 @@ namespace Ryujinx.Ava.UI.Views.Main
|
|||
ViewModel.AreMimeTypesRegistered = FileAssociationHelper.Install();
|
||||
if (ViewModel.AreMimeTypesRegistered)
|
||||
await ContentDialogHelper.CreateInfoDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesSuccessMessage], string.Empty, LocaleManager.Instance[LocaleKeys.InputDialogOk], string.Empty, string.Empty);
|
||||
else
|
||||
else
|
||||
{
|
||||
await ContentDialogHelper.CreateErrorDialog(LocaleManager.Instance[LocaleKeys.DialogInstallFileTypesErrorMessage]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue