From b8f48bcf640acae519602a26fd6c4ce49c04709b Mon Sep 17 00:00:00 2001 From: Ac_K Date: Thu, 1 Jun 2023 18:24:00 +0200 Subject: [PATCH] UI: Fix empty homebrew icon (#5189) * UI: Fix empty homebrew icon We currently don't check the icon size when we read it from the homebrew data. That could cause issues at UI side since the buffer isn't null but empty. Extra check have been added UI side too. (I cleaned up some files during my research too) Fixes #5188 * Remove additional check * Remove unused using --- .../UI/Helpers/BitmapArrayValueConverter.cs | 1 + .../UI/Views/Main/MainMenuBarView.axaml.cs | 2 -- .../App/ApplicationLibrary.cs | 18 ++++++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Ava/UI/Helpers/BitmapArrayValueConverter.cs b/src/Ryujinx.Ava/UI/Helpers/BitmapArrayValueConverter.cs index 3fd368f8..133f8dbc 100644 --- a/src/Ryujinx.Ava/UI/Helpers/BitmapArrayValueConverter.cs +++ b/src/Ryujinx.Ava/UI/Helpers/BitmapArrayValueConverter.cs @@ -21,6 +21,7 @@ namespace Ryujinx.Ava.UI.Helpers if (value is byte[] buffer && targetType == typeof(IImage)) { MemoryStream mem = new(buffer); + return new Bitmap(mem); } diff --git a/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs b/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs index 557528eb..f94b80d4 100644 --- a/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs +++ b/src/Ryujinx.Ava/UI/Views/Main/MainMenuBarView.axaml.cs @@ -9,9 +9,7 @@ using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.Windows; using Ryujinx.Common; using Ryujinx.Common.Utilities; -using Ryujinx.HLE.HOS; using Ryujinx.Modules; -using Ryujinx.Ui.App.Common; using Ryujinx.Ui.Common; using Ryujinx.Ui.Common.Configuration; using Ryujinx.Ui.Common.Helper; diff --git a/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs b/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs index 0407036a..f52af611 100644 --- a/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs +++ b/src/Ryujinx.Ui.Common/App/ApplicationLibrary.cs @@ -343,7 +343,14 @@ namespace Ryujinx.Ui.App.Common ulong nacpSize = reader.ReadUInt64(); // Reads and stores game icon as byte array - applicationIcon = Read(assetOffset + iconOffset, (int)iconSize); + if (iconSize > 0) + { + applicationIcon = Read(assetOffset + iconOffset, (int)iconSize); + } + else + { + applicationIcon = _nroIcon; + } // Read the NACP data Read(assetOffset + (int)nacpOffset, (int)nacpSize).AsSpan().CopyTo(controlHolder.ByteSpan); @@ -666,7 +673,14 @@ namespace Ryujinx.Ui.App.Common long iconSize = BitConverter.ToInt64(iconSectionInfo, 8); // Reads and stores game icon as byte array - applicationIcon = Read(assetOffset + iconOffset, (int)iconSize); + if (iconSize > 0) + { + applicationIcon = Read(assetOffset + iconOffset, (int)iconSize); + } + else + { + applicationIcon = _nroIcon; + } } else {