summaryrefslogtreecommitdiff
path: root/indra/llcommon/llsingleton.h
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2011-08-29 10:36:48 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2011-08-29 10:36:48 -0400
commitf054d44f9e2e0d152b1a0167b007eb10105487d6 (patch)
tree3cf567add6e532f212192a6c94bfaf17c7eecc76 /indra/llcommon/llsingleton.h
parent2e4dcca9e2049aa4a8c29820937b6a956d75e5d8 (diff)
parentd45995b80d6d90aad6714adf3237dc44589169ea (diff)
merg
Diffstat (limited to 'indra/llcommon/llsingleton.h')
-rw-r--r--indra/llcommon/llsingleton.h20
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