fix(ui): stop spurious "failed to read" logo errors in the portable build

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 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 12:58:19 -05:00
parent 5167b52cbd
commit f0867084f3

View File

@@ -1216,7 +1216,12 @@ void App::render()
} }
logoPath = util::getExecutableDirectory() + "/res/img/" + iconFile; 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_); DEBUG_LOGF("Loaded header logo from %s (%dx%d)\n", logoPath.c_str(), logo_w_, logo_h_);
} else { } else {
// Try embedded data fallback — use actual filename from path // 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()) std::string coinFile = (cit != coinElem.extraColors.end() && !cit->second.empty())
? cit->second : "logos/logo_dragonx_128.png"; ? cit->second : "logos/logo_dragonx_128.png";
std::string coinPath = util::getExecutableDirectory() + "/res/img/" + coinFile; 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_); DEBUG_LOGF("Loaded coin logo from %s (%dx%d)\n", coinPath.c_str(), coin_logo_w_, coin_logo_h_);
} else { } else {
// Try embedded resource fallback (Windows single-file distribution) // Try embedded resource fallback (Windows single-file distribution)