Prevent cached resource from being acquired while it is being destroyed

Fixes #158
This commit is contained in:
Sparkling Shampoo 2022-04-06 23:33:32 -04:00 committed by Nicholas Estelami
parent 0ef2d0c750
commit 1aa08caade

View File

@ -217,9 +217,12 @@ namespace Ship {
std::shared_ptr<Ship::Resource> ResourceMgr::GetCachedFile(std::string FilePath) { std::shared_ptr<Ship::Resource> ResourceMgr::GetCachedFile(std::string FilePath) {
auto resCacheFind = ResourceCache.find(FilePath); auto resCacheFind = ResourceCache.find(FilePath);
if (resCacheFind != ResourceCache.end()) if (resCacheFind != ResourceCache.end() &&
resCacheFind->second.use_count() > 0)
{
return resCacheFind->second; return resCacheFind->second;
}
else else
return nullptr; return nullptr;
} }