diff --git a/include/osgDB/ObjectWrapper b/include/osgDB/ObjectWrapper index 8003cb8a3..80424880f 100644 --- a/include/osgDB/ObjectWrapper +++ b/include/osgDB/ObjectWrapper @@ -15,6 +15,7 @@ #ifndef OSGDB_OBJECTWRAPPER #define OSGDB_OBJECTWRAPPER +#include #include #include @@ -169,6 +170,8 @@ protected: ObjectWrapperManager(); virtual ~ObjectWrapperManager(); + OpenThreads::ReentrantMutex _wrapperMutex; + WrapperMap _wrappers; CompressorMap _compressors; diff --git a/src/osgDB/ObjectWrapper.cpp b/src/osgDB/ObjectWrapper.cpp index 1b98cedb0..07f5e0a20 100644 --- a/src/osgDB/ObjectWrapper.cpp +++ b/src/osgDB/ObjectWrapper.cpp @@ -647,6 +647,8 @@ void ObjectWrapperManager::addWrapper( ObjectWrapper* wrapper ) { if ( !wrapper ) return; + OpenThreads::ScopedLock lock(_wrapperMutex); + WrapperMap::iterator itr = _wrappers.find( wrapper->getName() ); if ( itr!=_wrappers.end() ) { @@ -660,12 +662,16 @@ void ObjectWrapperManager::removeWrapper( ObjectWrapper* wrapper ) { if ( !wrapper ) return; + OpenThreads::ScopedLock lock(_wrapperMutex); + WrapperMap::iterator itr = _wrappers.find( wrapper->getName() ); if ( itr!=_wrappers.end() ) _wrappers.erase( itr ); } ObjectWrapper* ObjectWrapperManager::findWrapper( const std::string& name ) { + OpenThreads::ScopedLock lock(_wrapperMutex); + WrapperMap::iterator itr = _wrappers.find( name ); if ( itr!=_wrappers.end() ) return itr->second.get(); @@ -694,6 +700,8 @@ void ObjectWrapperManager::addCompressor( BaseCompressor* compressor ) { if ( !compressor ) return; + OpenThreads::ScopedLock lock(_wrapperMutex); + CompressorMap::iterator itr = _compressors.find( compressor->getName() ); if ( itr!=_compressors.end() ) { @@ -707,12 +715,16 @@ void ObjectWrapperManager::removeCompressor( BaseCompressor* compressor ) { if ( !compressor ) return; + OpenThreads::ScopedLock lock(_wrapperMutex); + CompressorMap::iterator itr = _compressors.find( compressor->getName() ); if ( itr!=_compressors.end() ) _compressors.erase( itr ); } BaseCompressor* ObjectWrapperManager::findCompressor( const std::string& name ) { + OpenThreads::ScopedLock lock(_wrapperMutex); + CompressorMap::iterator itr = _compressors.find( name ); if ( itr!=_compressors.end() ) return itr->second.get();