diff --git a/simgear/scene/model/ModelRegistry.cxx b/simgear/scene/model/ModelRegistry.cxx index f788162a..bcb5ec9c 100644 --- a/simgear/scene/model/ModelRegistry.cxx +++ b/simgear/scene/model/ModelRegistry.cxx @@ -280,19 +280,21 @@ ModelRegistry::readImage(const string& fileName, } -osg::Node* DefaultCachePolicy::find(const string& fileName, - const Options* opt) +osg::ref_ptr DefaultCachePolicy::find(const string& fileName, const Options* opt) { Registry* registry = Registry::instance(); - osg::Node* cached - = dynamic_cast(registry->getFromObjectCache(fileName)); - if (cached) - SG_LOG(SG_IO, SG_BULK, "Got cached model \"" - << fileName << "\""); +#if OSG_VERSION_LESS_THAN(3,4,0) + osg::ref_ptr cachedObject = registry->getFromObjectCache(fileName); +#else + osg::ref_ptr cachedObject = registry->getRefFromObjectCache(fileName); +#endif + + ref_ptr cachedNode = dynamic_cast(cachedObject.get()); + if (cachedNode.valid()) + SG_LOG(SG_IO, SG_BULK, "Got cached model \"" << fileName << "\""); else - SG_LOG(SG_IO, SG_BULK, "Reading model \"" - << fileName << "\""); - return cached; + SG_LOG(SG_IO, SG_BULK, "Reading model \"" << fileName << "\""); + return cachedNode; } void DefaultCachePolicy::addToCache(const string& fileName, diff --git a/simgear/scene/model/ModelRegistry.hxx b/simgear/scene/model/ModelRegistry.hxx index 8c8e7467..197bb197 100644 --- a/simgear/scene/model/ModelRegistry.hxx +++ b/simgear/scene/model/ModelRegistry.hxx @@ -132,7 +132,7 @@ struct DefaultProcessPolicy { struct DefaultCachePolicy { DefaultCachePolicy(const std::string& extension) {} - osg::Node* find(const std::string& fileName, + osg::ref_ptr find(const std::string& fileName, const osgDB::Options* opt); void addToCache(const std::string& filename, osg::Node* node); };