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 type = constructors.Where(x => x.ParameterList.Parameters.Count == 2).FirstOrDefault().ParameterList.Parameters[1].Type;
|
||||||
var model = context.Compilation.GetSemanticModel(type.SyntaxTree);
|
var model = context.Compilation.GetSemanticModel(type.SyntaxTree);
|
||||||
var typeSymbol = model.GetSymbolInfo(type).Symbol as INamedTypeSymbol;
|
var typeSymbol = model.GetSymbolInfo(type).Symbol as INamedTypeSymbol;
|
||||||
var fullName = typeSymbol.ToString();
|
var fullName = typeSymbol?.ToString();
|
||||||
generator.EnterScope("if (parameter != null)");
|
generator.EnterScope("if (parameter != null)");
|
||||||
generator.AppendLine($"return new {GetFullName(className, context)}(context, ({fullName})parameter);");
|
generator.AppendLine($"return new {GetFullName(className, context)}(context, ({fullName})parameter);");
|
||||||
generator.LeaveScope();
|
generator.LeaveScope();
|
||||||
|
|
@ -67,7 +67,7 @@ namespace Ryujinx.HLE.Generators
|
||||||
{
|
{
|
||||||
var typeSymbol = context.Compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetDeclaredSymbol(syntaxNode);
|
var typeSymbol = context.Compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetDeclaredSymbol(syntaxNode);
|
||||||
|
|
||||||
return typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
|
return typeSymbol?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(GeneratorInitializationContext context)
|
public void Initialize(GeneratorInitializationContext context)
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv
|
||||||
{
|
{
|
||||||
targetPrevAddress = InvalidAddress;
|
targetPrevAddress = InvalidAddress;
|
||||||
}
|
}
|
||||||
node = node.Previous;
|
node = node?.Previous;
|
||||||
_tree.Remove(prevAddress);
|
_tree.Remove(prevAddress);
|
||||||
_list.Remove(_dictionary[prevAddress]);
|
_list.Remove(_dictionary[prevAddress]);
|
||||||
_dictionary.Remove(prevAddress);
|
_dictionary.Remove(prevAddress);
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
// Get screen touch position
|
// Get screen touch position
|
||||||
if (!_enableMouse)
|
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)
|
if (!hasTouch)
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ namespace Ryujinx.Horizon.Kernel.Generators
|
||||||
{
|
{
|
||||||
string name = methodParameter.Identifier.Text;
|
string name = methodParameter.Identifier.Text;
|
||||||
string argName = GetPrefixedArgName(name);
|
string argName = GetPrefixedArgName(name);
|
||||||
string typeName = methodParameter.Type.ToString();
|
string typeName = methodParameter.Type?.ToString();
|
||||||
string canonicalTypeName = GetCanonicalTypeName(compilation, methodParameter.Type);
|
string canonicalTypeName = GetCanonicalTypeName(compilation, methodParameter.Type);
|
||||||
|
|
||||||
if (methodParameter.Modifiers.Any(SyntaxKind.OutKeyword))
|
if (methodParameter.Modifiers.Any(SyntaxKind.OutKeyword))
|
||||||
|
|
@ -329,7 +329,7 @@ namespace Ryujinx.Horizon.Kernel.Generators
|
||||||
{
|
{
|
||||||
string name = methodParameter.Identifier.Text;
|
string name = methodParameter.Identifier.Text;
|
||||||
string argName = GetPrefixedArgName(name);
|
string argName = GetPrefixedArgName(name);
|
||||||
string typeName = methodParameter.Type.ToString();
|
string typeName = methodParameter.Type?.ToString();
|
||||||
string canonicalTypeName = GetCanonicalTypeName(compilation, methodParameter.Type);
|
string canonicalTypeName = GetCanonicalTypeName(compilation, methodParameter.Type);
|
||||||
|
|
||||||
if (methodParameter.Modifiers.Any(SyntaxKind.OutKeyword))
|
if (methodParameter.Modifiers.Any(SyntaxKind.OutKeyword))
|
||||||
|
|
@ -415,9 +415,9 @@ namespace Ryujinx.Horizon.Kernel.Generators
|
||||||
private static string GetCanonicalTypeName(Compilation compilation, SyntaxNode syntaxNode)
|
private static string GetCanonicalTypeName(Compilation compilation, SyntaxNode syntaxNode)
|
||||||
{
|
{
|
||||||
TypeInfo typeInfo = compilation.GetSemanticModel(syntaxNode.SyntaxTree).GetTypeInfo(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}";
|
return $"{typeInfo.Type.ContainingNamespace.ToDisplayString()}.{typeInfo.Type.Name}";
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
private PlayerIndex _playerId;
|
private PlayerIndex _playerId;
|
||||||
private PlayerIndex _playerIdChoose;
|
private PlayerIndex _playerIdChoose;
|
||||||
private int _controller;
|
private int _controller;
|
||||||
private int _controllerNumber;
|
|
||||||
private string _controllerImage;
|
private string _controllerImage;
|
||||||
private int _device;
|
private int _device;
|
||||||
private object _configViewModel;
|
private object _configViewModel;
|
||||||
|
|
@ -247,8 +246,8 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
if (Program.PreviewerDetached)
|
if (Program.PreviewerDetached)
|
||||||
{
|
{
|
||||||
_mainWindow =
|
_mainWindow =
|
||||||
(MainWindow)((IClassicDesktopStyleApplicationLifetime)Application.Current
|
(MainWindow)((IClassicDesktopStyleApplicationLifetime)Application.Current?
|
||||||
.ApplicationLifetime).MainWindow;
|
.ApplicationLifetime)?.MainWindow;
|
||||||
|
|
||||||
AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner);
|
AvaloniaKeyboardDriver = new AvaloniaKeyboardDriver(owner);
|
||||||
|
|
||||||
|
|
@ -519,7 +518,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
{
|
{
|
||||||
ProfilesList.Clear();
|
ProfilesList.Clear();
|
||||||
|
|
||||||
string basePath = GetProfileBasePath();
|
string basePath = GetProfileBasePath() ?? string.Empty;
|
||||||
|
|
||||||
if (!Directory.Exists(basePath))
|
if (!Directory.Exists(basePath))
|
||||||
{
|
{
|
||||||
|
|
@ -773,11 +772,11 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
|
|
||||||
if (IsKeyboard)
|
if (IsKeyboard)
|
||||||
{
|
{
|
||||||
config = (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig();
|
config = (ConfigViewModel as KeyboardInputViewModel)?.Config.GetConfig();
|
||||||
}
|
}
|
||||||
else if (IsController)
|
else if (IsController)
|
||||||
{
|
{
|
||||||
config = (ConfigViewModel as ControllerInputViewModel).Config.GetConfig();
|
config = (ConfigViewModel as ControllerInputViewModel)?.Config.GetConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
config.ControllerType = Controllers[_controller].Type;
|
config.ControllerType = Controllers[_controller].Type;
|
||||||
|
|
@ -842,18 +841,18 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
|
||||||
|
|
||||||
if (device.Type == DeviceType.Keyboard)
|
if (device.Type == DeviceType.Keyboard)
|
||||||
{
|
{
|
||||||
var inputConfig = (ConfigViewModel as KeyboardInputViewModel).Config;
|
var inputConfig = ((KeyboardInputViewModel)ConfigViewModel).Config;
|
||||||
inputConfig.Id = device.Id;
|
inputConfig.Id = device.Id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var inputConfig = (ConfigViewModel as ControllerInputViewModel).Config;
|
var inputConfig = ((ControllerInputViewModel)ConfigViewModel).Config;
|
||||||
inputConfig.Id = device.Id.Split(" ")[0];
|
inputConfig.Id = device.Id.Split(" ")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = !IsController
|
var config = !IsController
|
||||||
? (ConfigViewModel as KeyboardInputViewModel).Config.GetConfig()
|
? ((KeyboardInputViewModel)ConfigViewModel).Config.GetConfig()
|
||||||
: (ConfigViewModel as ControllerInputViewModel).Config.GetConfig();
|
: ((ControllerInputViewModel)ConfigViewModel).Config.GetConfig();
|
||||||
config.ControllerType = Controllers[_controller].Type;
|
config.ControllerType = Controllers[_controller].Type;
|
||||||
config.PlayerIndex = _playerId;
|
config.PlayerIndex = _playerId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2251,7 +2251,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
switch (operationOutcome)
|
switch (operationOutcome)
|
||||||
{
|
{
|
||||||
case XCIFileTrimmer.OperationOutcome.Successful:
|
case XCIFileTrimmer.OperationOutcome.Successful:
|
||||||
if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
if (desktop.MainWindow is MainWindow mainWindow)
|
if (desktop.MainWindow is MainWindow mainWindow)
|
||||||
mainWindow.LoadApplications();
|
mainWindow.LoadApplications();
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
_modJsonPath = Path.Combine(AppDataManager.GamesDirPath, applicationId.ToString("x16"), "mods.json");
|
_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);
|
LoadMods(applicationId, _installedDlcIds);
|
||||||
|
|
@ -117,8 +117,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
foreach (var mod in modCache.RomfsDirs)
|
foreach (var mod in modCache.RomfsDirs)
|
||||||
{
|
{
|
||||||
var modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd);
|
var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||||
if (Mods.All(x => x.Path != mod.Path.Parent.FullName))
|
if (Mods.All(x => x.Path != mod.Path.Parent?.FullName))
|
||||||
{
|
{
|
||||||
Mods.Add(modModel);
|
Mods.Add(modModel);
|
||||||
}
|
}
|
||||||
|
|
@ -131,8 +131,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
|
|
||||||
foreach (var mod in modCache.ExefsDirs)
|
foreach (var mod in modCache.ExefsDirs)
|
||||||
{
|
{
|
||||||
var modModel = new ModModel(mod.Path.Parent.FullName, mod.Name, mod.Enabled, inSd);
|
var modModel = new ModModel(mod.Path.Parent?.FullName, mod.Name, mod.Enabled, inSd);
|
||||||
if (Mods.All(x => x.Path != mod.Path.Parent.FullName))
|
if (Mods.All(x => x.Path != mod.Path.Parent?.FullName))
|
||||||
{
|
{
|
||||||
Mods.Add(modModel);
|
Mods.Add(modModel);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ namespace Ryujinx.Ava.UI.Views.Main
|
||||||
|
|
||||||
private async void StopEmulation_Click(object sender, RoutedEventArgs e)
|
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)
|
private void PauseEmulation_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue