diff options
author | Oz Linden <oz@lindenlab.com> | 2011-08-25 09:27:34 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-08-25 09:27:34 -0400 |
commit | e6239b7978fb9f05d2c8c7cf42b9277f4a5f7c52 (patch) | |
tree | 17080b4ffa8a59a5b9c158edaf9e60f9af2a67b4 /indra/llcommon/llsingleton.h | |
parent | 66cac05cfb1236c3c1607dff27babf873c29a679 (diff) | |
parent | 6484dbf28cb8b6ffa745fe9b26beae58d3c68441 (diff) |
merge changes for storm-1571
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 |