fix double free for model animation unloading

This commit is contained in:
arthur.jamet
2021-06-02 16:47:05 +02:00
parent 37fb527d5b
commit f3d9effb83
+5 -3
View File
@@ -60,11 +60,13 @@ namespace RAY {
{};
std::shared_ptr<::ModelAnimation> fetch(const std::string &path, int *counter)
{
::ModelAnimation *animations = this->_dataLoader(path.c_str(), counter);
unsigned int animCount = *counter;
if (this->_cache.find(path) == this->_cache.end())
this->_cache.emplace(path, std::shared_ptr<::ModelAnimation>(
this->_dataLoader(path.c_str(), counter), [this, counter](::ModelAnimation *p) {
this->_dataUnloader(p, *counter);
delete p;
animations, [this, animCount](::ModelAnimation *p) {
this->_dataUnloader(p, animCount);
}));
return _cache[path];
};