Added mutex to resource manager cache reading to avoid a potential race condition. We hope this is the actual bug we saw.

This commit is contained in:
2016-02-04 11:53:11 +01:00
parent bd2da7bc9f
commit c87e4d4fd6
+3
View File
@@ -200,6 +200,8 @@ static T* ResourceManager::Load(const std::string& resourceName, Resource* paren
} }
//If resource has already been cached and completely loaded. //If resource has already been cached and completely loaded.
{
boost::lock_guard<decltype(m_Mutex)> guard(m_Mutex);
it = m_ResourceCache.find(cacheKey); it = m_ResourceCache.find(cacheKey);
if (it != m_ResourceCache.end()) { if (it != m_ResourceCache.end()) {
if (it->second != nullptr) { if (it->second != nullptr) {
@@ -209,6 +211,7 @@ static T* ResourceManager::Load(const std::string& resourceName, Resource* paren
throw Resource::FailedLoadingException(); throw Resource::FailedLoadingException();
} }
} }
}
//If resource is not cached.. //If resource is not cached..
if (UseThreading && async) { if (UseThreading && async) {