From f0867084f3756fc87196707d159fd2a7274b482f Mon Sep 17 00:00:00 2001 From: DanS Date: Sat, 13 Jun 2026 12:58:19 -0500 Subject: [PATCH] fix(ui): stop spurious "failed to read" logo errors in the portable build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The header and coin logos load disk-first (for dev builds / theme drop-ins) and fall back to the copies embedded in the exe. The portable single-file build has no res/img/ folder beside it, so the disk read always failed and logged "LoadTextureFromFile: failed to read ..." before the (successful) embedded fallback. Guard each disk load with std::filesystem::exists() so the missing file is skipped silently and we go straight to the embedded logo — no error line, logos unchanged. Co-Authored-By: Claude Opus 4.8 --- src/app.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index 521ea28..51713c9 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -1216,7 +1216,12 @@ void App::render() } logoPath = util::getExecutableDirectory() + "/res/img/" + iconFile; } - if (util::LoadTextureFromFile(logoPath.c_str(), &logo_tex_, &logo_w_, &logo_h_)) { + // Only attempt the disk read when the file is actually present (dev build / theme drop-in). + // The portable single-file build has no res/img/ beside it, so skip straight to the + // embedded copy instead of logging a spurious "failed to read". + std::error_code logoEc; + if (std::filesystem::exists(logoPath, logoEc) && + util::LoadTextureFromFile(logoPath.c_str(), &logo_tex_, &logo_w_, &logo_h_)) { DEBUG_LOGF("Loaded header logo from %s (%dx%d)\n", logoPath.c_str(), logo_w_, logo_h_); } else { // Try embedded data fallback — use actual filename from path @@ -1251,7 +1256,9 @@ void App::render() std::string coinFile = (cit != coinElem.extraColors.end() && !cit->second.empty()) ? cit->second : "logos/logo_dragonx_128.png"; std::string coinPath = util::getExecutableDirectory() + "/res/img/" + coinFile; - if (util::LoadTextureFromFile(coinPath.c_str(), &coin_logo_tex_, &coin_logo_w_, &coin_logo_h_)) { + std::error_code coinEc; + if (std::filesystem::exists(coinPath, coinEc) && + util::LoadTextureFromFile(coinPath.c_str(), &coin_logo_tex_, &coin_logo_w_, &coin_logo_h_)) { DEBUG_LOGF("Loaded coin logo from %s (%dx%d)\n", coinPath.c_str(), coin_logo_w_, coin_logo_h_); } else { // Try embedded resource fallback (Windows single-file distribution)