mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Fix crash when adding a NULL object to the cache
This commit is contained in:
parent
4c174ecd12
commit
50d7eb8e54
3 changed files with 12 additions and 4 deletions
|
@ -141,10 +141,7 @@ osg::ref_ptr<const BulletShape> BulletShapeManager::getShape(const std::string &
|
||||||
node->accept(visitor);
|
node->accept(visitor);
|
||||||
shape = visitor.getShape();
|
shape = visitor.getShape();
|
||||||
if (!shape)
|
if (!shape)
|
||||||
{
|
|
||||||
mCache->addEntryToObjectCache(normalized, NULL);
|
|
||||||
return osg::ref_ptr<BulletShape>();
|
return osg::ref_ptr<BulletShape>();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mCache->addEntryToObjectCache(normalized, shape);
|
mCache->addEntryToObjectCache(normalized, shape);
|
||||||
|
@ -158,7 +155,8 @@ osg::ref_ptr<BulletShapeInstance> BulletShapeManager::cacheInstance(const std::s
|
||||||
mVFS->normalizeFilename(normalized);
|
mVFS->normalizeFilename(normalized);
|
||||||
|
|
||||||
osg::ref_ptr<BulletShapeInstance> instance = createInstance(normalized);
|
osg::ref_ptr<BulletShapeInstance> instance = createInstance(normalized);
|
||||||
mInstanceCache->addEntryToObjectCache(normalized, instance.get());
|
if (instance)
|
||||||
|
mInstanceCache->addEntryToObjectCache(normalized, instance.get());
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,11 @@ namespace Resource
|
||||||
|
|
||||||
void MultiObjectCache::addEntryToObjectCache(const std::string &filename, osg::Object *object)
|
void MultiObjectCache::addEntryToObjectCache(const std::string &filename, osg::Object *object)
|
||||||
{
|
{
|
||||||
|
if (!object)
|
||||||
|
{
|
||||||
|
OSG_ALWAYS << " trying to add NULL object to cache for " << filename << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||||
_objectCache.insert(std::make_pair(filename, object));
|
_objectCache.insert(std::make_pair(filename, object));
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,11 @@ ObjectCache::~ObjectCache()
|
||||||
|
|
||||||
void ObjectCache::addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp)
|
void ObjectCache::addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp)
|
||||||
{
|
{
|
||||||
|
if (!object)
|
||||||
|
{
|
||||||
|
OSG_ALWAYS << " trying to add NULL object to cache for " << filename << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_objectCacheMutex);
|
||||||
_objectCache[filename]=ObjectTimeStampPair(object,timestamp);
|
_objectCache[filename]=ObjectTimeStampPair(object,timestamp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue