diff --git a/include/osg/ObserverNodePath b/include/osg/ObserverNodePath index d79633c70..aaa03b32a 100644 --- a/include/osg/ObserverNodePath +++ b/include/osg/ObserverNodePath @@ -73,4 +73,4 @@ class OSG_EXPORT ObserverNodePath : public osg::Observer } -#endif \ No newline at end of file +#endif diff --git a/src/osg/Observer.cpp b/src/osg/Observer.cpp index 6c1d6a483..07f636087 100644 --- a/src/osg/Observer.cpp +++ b/src/osg/Observer.cpp @@ -68,4 +68,4 @@ void ObserverSet::signalObjectDeleted(void* ptr) (*itr)->objectDeleted(ptr); } _observers.clear(); -} \ No newline at end of file +} diff --git a/src/osg/Referenced.cpp b/src/osg/Referenced.cpp index ccc973fc8..7679828a7 100644 --- a/src/osg/Referenced.cpp +++ b/src/osg/Referenced.cpp @@ -94,6 +94,18 @@ OpenThreads::Mutex* Observer::getGlobalObserverMutex() return s_ReferencedGlobalMutext.get(); } +// helper class for forcing the global mutex to be constructed when the library is loaded. +struct InitGlobalMutexes +{ + InitGlobalMutexes() + { + Referenced::getGlobalReferencedMutex(); + Observer::getGlobalObserverMutex(); + } +}; +static InitGlobalMutexes s_initGlobalMutexes; + + #if !defined(_OSG_REFERENCED_USE_ATOMIC_OPERATIONS) static bool s_useThreadSafeReferenceCounting = getenv("OSG_THREAD_SAFE_REF_UNREF")!=0; #endif