diff --git a/components/resource/objectcache.cpp b/components/resource/objectcache.cpp index 54576a122..17368f34f 100644 --- a/components/resource/objectcache.cpp +++ b/components/resource/objectcache.cpp @@ -23,12 +23,10 @@ namespace Resource ObjectCache::ObjectCache(): osg::Referenced(true) { -// OSG_NOTICE<<"Constructed ObjectCache"< scene = getTemplate(name); osg::ref_ptr 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(scene.get())); + return cloned; }