From d2a4e48f81bc637ce130cd94bd091f97658c6676 Mon Sep 17 00:00:00 2001 From: Wolfgang Haupt Date: Sun, 2 Feb 2020 20:01:21 +0100 Subject: [PATCH] Fix TextureCache::CacheImage does not fill texture outparam If the texture out parameter is given, it's expected to be filled. However when requesting a texture which is already in the processlist, the method fails to fill the requested texture. This resulted in a hard to trigger bug, where the default texture is rendered instead of the real thumbnail, although the thumbnail is available. --- xbmc/TextureCache.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/xbmc/TextureCache.cpp b/xbmc/TextureCache.cpp index aebac145b182f..1d832c10af396 100644 --- a/xbmc/TextureCache.cpp +++ b/xbmc/TextureCache.cpp @@ -7,18 +7,19 @@ */ #include "TextureCache.h" +#include "ServiceBroker.h" #include "TextureCacheJob.h" +#include "URL.h" #include "filesystem/File.h" +#include "guilib/Texture.h" #include "profiles/ProfileManager.h" -#include "threads/SingleLock.h" -#include "utils/Crc32.h" #include "settings/AdvancedSettings.h" #include "settings/SettingsComponent.h" -#include "utils/log.h" -#include "utils/URIUtils.h" +#include "threads/SingleLock.h" +#include "utils/Crc32.h" #include "utils/StringUtils.h" -#include "URL.h" -#include "ServiceBroker.h" +#include "utils/URIUtils.h" +#include "utils/log.h" using namespace XFILE; @@ -161,7 +162,20 @@ std::string CTextureCache::CacheImage(const std::string &image, CBaseTexture **t CTextureDetails tempDetails; if (!details) details = &tempDetails; - return GetCachedImage(url, *details, true); + + std::string cachedpath = GetCachedImage(url, *details, true); + if (!cachedpath.empty()) + { + if (texture) + *texture = CBaseTexture::LoadFromFile(cachedpath, 0, 0); + } + else + { + CLog::Log(LOGDEBUG, "CTextureCache::%s - Return NULL texture because cache is not ready", + __FUNCTION__); + } + + return cachedpath; } bool CTextureCache::CacheImage(const std::string &image, CTextureDetails &details)