diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 171bcbb17d..15718d4ec9 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -355,13 +355,20 @@ void GameInfo::FinishPendingTextureLoads(Draw::DrawContext *draw) { } void GameInfo::SetupTexture(Draw::DrawContext *thin3d, GameInfoTex &tex) { + if (tex.timeLoaded) { + // Failed before, skip. + return; + } + if (tex.data.empty()) { + tex.timeLoaded = time_now_d(); + return; + } using namespace Draw; // TODO: Use TempImage to semi-load the image in the worker task, then here we // could just call CreateTextureFromTempImage. tex.texture = CreateTextureFromFileData(thin3d, (const uint8_t *)tex.data.data(), (int)tex.data.size(), ImageFileType::DETECT, false, GetTitle().c_str()); - if (tex.texture) { - tex.timeLoaded = time_now_d(); - } else { + tex.timeLoaded = time_now_d(); + if (!tex.texture) { ERROR_LOG(G3D, "Failed creating texture (%s) from %d-byte file", GetTitle().c_str(), (int)tex.data.size()); } } diff --git a/UI/GameInfoCache.h b/UI/GameInfoCache.h index 5550276a5b..f251aea494 100644 --- a/UI/GameInfoCache.h +++ b/UI/GameInfoCache.h @@ -69,11 +69,15 @@ struct GameInfoTex { Draw::Texture *texture = nullptr; // The time at which the Icon and the BG were loaded. // Can be useful to fade them in smoothly once they appear. + // Also, timeLoaded != 0 && texture == nullptr means that the load failed. double timeLoaded = 0.0; std::atomic dataLoaded{}; // Can ONLY be called from the main thread! void Clear(); + bool Failed() const { + return timeLoaded != 0.0 && !texture; + } }; class GameInfo { diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 5669f55b52..b32e3e63ef 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -87,7 +87,7 @@ public: UIContext &dc = *screenManager()->getUIContext(); const Style &textStyle = dc.theme->popupStyle; - std::shared_ptr ginfo = g_gameInfoCache->GetInfo(screenManager()->getDrawContext(), savePath_, GameInfoFlags::PARAM_SFO | GameInfoFlags::SIZE); + std::shared_ptr ginfo = g_gameInfoCache->GetInfo(screenManager()->getDrawContext(), savePath_, GameInfoFlags::PARAM_SFO | GameInfoFlags::ICON | GameInfoFlags::SIZE); if (!ginfo->Ready(GameInfoFlags::PARAM_SFO)) return; @@ -294,7 +294,7 @@ void SavedataButton::UpdateText(const std::shared_ptr &ginfo) { } void SavedataButton::Draw(UIContext &dc) { - std::shared_ptr ginfo = g_gameInfoCache->GetInfo(dc.GetDrawContext(), savePath_, GameInfoFlags::PARAM_SFO | GameInfoFlags::SIZE); + std::shared_ptr ginfo = g_gameInfoCache->GetInfo(dc.GetDrawContext(), savePath_, GameInfoFlags::ICON | GameInfoFlags::PARAM_SFO | GameInfoFlags::SIZE); Draw::Texture *texture = 0; u32 color = 0, shadowColor = 0; using namespace UI;