diff --git a/src/osg/Uniform.cpp b/src/osg/Uniform.cpp index 5c5583f81..a7fa4db2f 100644 --- a/src/osg/Uniform.cpp +++ b/src/osg/Uniform.cpp @@ -967,12 +967,13 @@ GLenum Uniform::getInternalArrayType( Type t ) } } -typedef std::map UniformNameIDMap; -static OpenThreads::Mutex s_mutex_uniformNameIDMap; -static UniformNameIDMap s_uniformNameIDMap; unsigned int Uniform::getNameID(const std::string& name) { + typedef std::map UniformNameIDMap; + static OpenThreads::Mutex s_mutex_uniformNameIDMap; + static UniformNameIDMap s_uniformNameIDMap; + OpenThreads::ScopedLock lock(s_mutex_uniformNameIDMap); UniformNameIDMap::iterator it = s_uniformNameIDMap.find(name); if (it != s_uniformNameIDMap.end()) @@ -984,6 +985,9 @@ unsigned int Uniform::getNameID(const std::string& name) return id; } +// Use a proxy to force the initialization of the static variables in the Unifrom::getNameID() method during static initialization +OSG_INIT_SINGLETON_PROXY(UniformNameIDStaticInitializationProxy, Uniform::getNameID(std::string())) + /////////////////////////////////////////////////////////////////////////// // value constructors for single-element (ie: non-array) uniforms diff --git a/src/osgViewer/Scene.cpp b/src/osgViewer/Scene.cpp index d9af8002d..86133b03c 100644 --- a/src/osgViewer/Scene.cpp +++ b/src/osgViewer/Scene.cpp @@ -70,7 +70,7 @@ static SceneSingleton& getSceneSingleton() return s_sceneSingleton; } -// Use a proxy to force the initialization of the the SceneSingleton during static initialization +// Use a proxy to force the initialization of the SceneSingleton during static initialization OSG_INIT_SINGLETON_PROXY(SceneSingletonProxy, getSceneSingleton()) }