mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-04 02:48:54 +02:00
misc: chore: Fix numerous NullReferenceExceptions, InvalidOperationExceptions
This commit is contained in:
@@ -88,11 +88,16 @@ namespace Ryujinx.UI.App.Common
|
||||
private static byte[] GetResourceBytes(string resourceName)
|
||||
{
|
||||
Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
|
||||
byte[] resourceByteArray = new byte[resourceStream.Length];
|
||||
if (resourceStream != null)
|
||||
{
|
||||
byte[] resourceByteArray = new byte[resourceStream.Length];
|
||||
|
||||
resourceStream.ReadExactly(resourceByteArray);
|
||||
resourceStream.ReadExactly(resourceByteArray);
|
||||
|
||||
return resourceByteArray;
|
||||
return resourceByteArray;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/// <exception cref="Ryujinx.HLE.Exceptions.InvalidNpdmException">The npdm file doesn't contain valid data.</exception>
|
||||
@@ -1178,7 +1183,7 @@ namespace Ryujinx.UI.App.Common
|
||||
{
|
||||
string extension = Path.GetExtension(applicationPath)?.ToLower();
|
||||
|
||||
using FileStream file = new(applicationPath, FileMode.Open, FileAccess.Read);
|
||||
using FileStream file = new(applicationPath ?? string.Empty, FileMode.Open, FileAccess.Read);
|
||||
|
||||
if (extension == ".nsp" || extension == ".pfs0" || extension == ".xci")
|
||||
{
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace Ryujinx.UI.Common.Helper
|
||||
|
||||
Logger.Debug?.Print(LogClass.Application, $"Adding type association {ext}");
|
||||
using var openCmd = key.CreateSubKey(@"shell\open\command");
|
||||
openCmd.SetValue("", $"\"{Environment.ProcessPath}\" \"%1\"");
|
||||
openCmd?.SetValue("", $"\"{Environment.ProcessPath}\" \"%1\"");
|
||||
Logger.Debug?.Print(LogClass.Application, $"Added type association {ext}");
|
||||
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace Ryujinx.UI.Common.SystemInfo
|
||||
{
|
||||
foreach (var cpuObj in cpuObjs)
|
||||
{
|
||||
return cpuObj["Name"].ToString().Trim();
|
||||
return cpuObj["Name"].ToString()?.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
return Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER").Trim();
|
||||
return Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER")?.Trim();
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
||||
Reference in New Issue
Block a user