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
1 changed files with 5 additions and 2 deletions

View File

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