diff options
author | Oz Linden <oz@lindenlab.com> | 2011-08-25 13:27:52 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-08-25 13:27:52 -0400 |
commit | 4057afd29161ad9cb69674ee608e48bc9e46a559 (patch) | |
tree | 058c53cb19d9b3e85fb0f9b70623c563704cdf17 /indra/llcommon/llsingleton.h | |
parent | 0f1dea30f827f920d2323d9450826f1a4baaa10b (diff) | |
parent | 7c222dfd136a4bb97700b390f8adbef6fe67cf5d (diff) |
merge changes for storm-1268
Diffstat (limited to 'indra/llcommon/llsingleton.h')
-rw-r--r-- | indra/llcommon/llsingleton.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 7aee1bb85f..00757be277 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -100,12 +100,6 @@ private: DELETED } EInitState; - static void deleteSingleton() - { - delete getData().mSingletonInstance; - getData().mSingletonInstance = NULL; - } - // stores pointer to singleton instance // and tracks initialization state of singleton struct SingletonInstanceData @@ -120,7 +114,11 @@ private: ~SingletonInstanceData() { - deleteSingleton(); + SingletonInstanceData& data = getData(); + if (data.mInitState != DELETED) + { + deleteSingleton(); + } } }; @@ -132,6 +130,14 @@ public: data.mInitState = DELETED; } + // Can be used to control when the singleton is deleted. Not normally needed. + static void deleteSingleton() + { + delete getData().mSingletonInstance; + getData().mSingletonInstance = NULL; + getData().mInitState = DELETED; + } + static SingletonInstanceData& getData() { // this is static to cache the lookup results |