From c69cc91f000f9a764d96fd31f00566c339562f84 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 29 May 2015 07:31:11 +0200 Subject: [PATCH] HiresTexture: Fix prefetching with broken textures --- Source/Core/VideoCommon/HiresTextures.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Core/VideoCommon/HiresTextures.cpp b/Source/Core/VideoCommon/HiresTextures.cpp index ac764fcd4f..c29e15261e 100644 --- a/Source/Core/VideoCommon/HiresTextures.cpp +++ b/Source/Core/VideoCommon/HiresTextures.cpp @@ -190,14 +190,20 @@ void HiresTexture::Prefetch() // But bad luck, SOIL isn't, so TODO: remove SOIL usage here and use libpng directly // Also TODO: remove s_textureCacheAquireMutex afterwards. It won't be needed as the main mutex will be locked rarely //lk.unlock(); - std::shared_ptr ptr(Load(base_filename, 0, 0)); + HiresTexture* t = Load(base_filename, 0, 0); //lk.lock(); - - iter = s_textureCache.insert(iter, std::make_pair(base_filename, ptr)); + if (t) + { + std::shared_ptr ptr(t); + iter = s_textureCache.insert(iter, std::make_pair(base_filename, ptr)); + } } - for (const Level& l : iter->second->m_levels) + if (iter != s_textureCache.end()) { - size_sum += l.data_size; + for (const Level& l : iter->second->m_levels) + { + size_sum += l.data_size; + } } }