From 252d342cc57180c9090c6083ccc7b58f73bcb0cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 10 Jun 2025 14:57:26 +0200 Subject: [PATCH] Fix another texture replacement crash (only happens with broken png texture files). Fix a warning too. --- Common/File/VFS/DirectoryReader.cpp | 6 +++++- Core/Config.cpp | 10 +++++++++- GPU/Common/ReplacedTexture.cpp | 1 - GPU/Common/SplineCommon.h | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Common/File/VFS/DirectoryReader.cpp b/Common/File/VFS/DirectoryReader.cpp index 01d0267615..6e13eb6ad9 100644 --- a/Common/File/VFS/DirectoryReader.cpp +++ b/Common/File/VFS/DirectoryReader.cpp @@ -97,10 +97,14 @@ size_t DirectoryReader::Read(VFSOpenFile *vfsOpenFile, void *buffer, size_t leng void DirectoryReader::CloseFile(VFSOpenFile *vfsOpenFile) { DirectoryReaderOpenFile *openFile = (DirectoryReaderOpenFile *)vfsOpenFile; + _dbg_assert_(openFile); + if (!openFile) { + return; + } _dbg_assert_(openFile->file != nullptr); if (openFile->file) { fclose(openFile->file); + openFile->file = nullptr; } - openFile->file = nullptr; delete openFile; } diff --git a/Core/Config.cpp b/Core/Config.cpp index 6b8c868d17..b216791189 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -214,6 +214,14 @@ static float DefaultUISaturation() { return IsVREnabled() ? 1.5f : 1.0f; } +static int DefaultUIScaleFactor() { +#if PPSSPP_PLATFORM(WINDOWS) + return -1; +#else + return 0; +#endif +} + static const ConfigSetting generalSettings[] = { ConfigSetting("FirstRun", &g_Config.bFirstRun, true, CfgFlag::DEFAULT), ConfigSetting("RunCount", &g_Config.iRunCount, 0, CfgFlag::DEFAULT), @@ -337,7 +345,7 @@ static const ConfigSetting generalSettings[] = { ConfigSetting("ShowGPOLEDs", &g_Config.bShowGPOLEDs, false, CfgFlag::PER_GAME), - ConfigSetting("UIScaleFactor", &g_Config.iUIScaleFactor, false, CfgFlag::DEFAULT), + ConfigSetting("UIScaleFactor", &g_Config.iUIScaleFactor, &DefaultUIScaleFactor, CfgFlag::DEFAULT), ConfigSetting("VulkanDisableImplicitLayers", &g_Config.bVulkanDisableImplicitLayers, false, CfgFlag::DEFAULT), }; diff --git a/GPU/Common/ReplacedTexture.cpp b/GPU/Common/ReplacedTexture.cpp index 8ba7d4ce3a..ee1ef5e736 100644 --- a/GPU/Common/ReplacedTexture.cpp +++ b/GPU/Common/ReplacedTexture.cpp @@ -681,7 +681,6 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference out.resize(level.w * level.h * 4); if (!png_image_finish_read(&png, nullptr, &out[0], level.w * 4, nullptr)) { ERROR_LOG(Log::TexReplacement, "Could not load texture replacement: %s - %s", filename.c_str(), png.message); - vfs_->CloseFile(openFile); out.resize(0); return LoadLevelResult::LOAD_ERROR; } diff --git a/GPU/Common/SplineCommon.h b/GPU/Common/SplineCommon.h index bec1fea09d..eadcaffed5 100644 --- a/GPU/Common/SplineCommon.h +++ b/GPU/Common/SplineCommon.h @@ -64,6 +64,8 @@ struct SurfaceInfo { if (tess_u > 2) tess_u = HALF_CEIL(tess_u); if (tess_v > 2) tess_v = HALF_CEIL(tess_v); break; + default: + break; } } };