Keep a reference to the original scene template for as long as the instance is used

coverity_scan
scrawl 9 years ago
parent 778bce3ae9
commit 41233fc8e5

@ -23,12 +23,10 @@ namespace Resource
ObjectCache::ObjectCache():
osg::Referenced(true)
{
// OSG_NOTICE<<"Constructed ObjectCache"<<std::endl;
}
ObjectCache::~ObjectCache()
{
// OSG_NOTICE<<"Destructed ObjectCache"<<std::endl;
}
void ObjectCache::addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp)

@ -373,6 +373,10 @@ namespace Resource
{
osg::ref_ptr<const osg::Node> scene = getTemplate(name);
osg::ref_ptr<osg::Node> cloned = osg::clone(scene.get(), SceneUtil::CopyOp());
// add a ref to the original template, to hint to the cache that it's still being used and should be kept in cache
cloned->getOrCreateUserDataContainer()->addUserObject(const_cast<osg::Node*>(scene.get()));
return cloned;
}

Loading…
Cancel
Save