diff options
author | Leslie Linden <leslie@lindenlab.com> | 2011-09-07 13:58:19 -0700 |
---|---|---|
committer | Leslie Linden <leslie@lindenlab.com> | 2011-09-07 13:58:19 -0700 |
commit | 78821c51a1f7d5fcc6e4a2678bfd3446ccfaee36 (patch) | |
tree | 51da53114f257ca57c2aa36da655019b75cf0269 /indra/llcommon/llsingleton.h | |
parent | c64bd7d5cb28fc221716e866ff9c9a28c22e69ce (diff) | |
parent | fef401a1768bae9bfb23a13549fa3a5005f2c7ae (diff) |
Merge from viewer-experience
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 |