diff --git a/src/osgDB/Registry.cpp b/src/osgDB/Registry.cpp index 494c44bc9..c64f612b4 100644 --- a/src/osgDB/Registry.cpp +++ b/src/osgDB/Registry.cpp @@ -1250,9 +1250,21 @@ ReaderWriter::ReadResult Registry::readImplementation(const ReadFunctor& readFun ReaderWriter::ReadResult rr = read(readFunctor); if (rr.validObject()) { - // update cache with new entry. - OSG_INFO<<"Adding to object cache "< lock(_objectCacheMutex); + ObjectCache::iterator oitr = _objectCache.find(file); + if (oitr != _objectCache.end()) + { + OSG_INFO << "returning cached instanced of " << file << std::endl; + if (readFunctor.isValid(oitr->second.first.get())) return ReaderWriter::ReadResult(oitr->second.first.get(), ReaderWriter::ReadResult::FILE_LOADED_FROM_CACHE); + else return ReaderWriter::ReadResult("Error file does not contain an osg::Object"); + } + // update cache with new entry. + OSG_INFO<<"Adding to object cache "<