diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 1cbefb1cd05f53ce3487d48b555ce9d60a539c5d..165344ed194d531079b434b5d90c046adfe8f005 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -83,8 +83,10 @@ class LLSingleton : private boost::noncopyable void construct() { + sReentrantConstructorGuard = true; mSingletonInstance = new DERIVED_TYPE(); mInitState = INITIALIZING; + sReentrantConstructorGuard = false; } ~SingletonInstanceData() @@ -174,7 +176,7 @@ class LLSingleton : private boost::noncopyable // Use this to avoid accessing singletons before the can safely be constructed static bool instanceExists() { - return getSingletonData().mInitState == INITIALIZED; + return sReentrantConstructorGuard || getSingletonData().mInitState == INITIALIZED; } // Has this singleton already been deleted? @@ -194,6 +196,11 @@ class LLSingleton : private boost::noncopyable } virtual void initSingleton() {} + + static bool sReentrantConstructorGuard; }; +template<typename T> +bool LLSingleton<T>::sReentrantConstructorGuard = false; + #endif