diff options
| author | Sparkling Shampoo <sparkling.shampoo@gmail.com> | 2022-04-06 23:33:32 -0400 |
|---|---|---|
| committer | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2022-04-16 19:49:36 -0400 |
| commit | 1aa08caade5bcb8a840eced6a71a74abddbc81cf (patch) | |
| tree | eec10473917e44b593420a8a3101c955cbd7a18b | |
| parent | 0ef2d0c750fec74716d9113a68a4c0181640028d (diff) | |
Prevent cached resource from being acquired while it is being destroyed
Fixes #158
| -rw-r--r-- | libultraship/libultraship/ResourceMgr.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libultraship/libultraship/ResourceMgr.cpp b/libultraship/libultraship/ResourceMgr.cpp index e6f3c8a0a..b4d7b76a8 100644 --- a/libultraship/libultraship/ResourceMgr.cpp +++ b/libultraship/libultraship/ResourceMgr.cpp @@ -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; } |
