diff options
author | Paul ProductEngine <pguslisty@productengine.com> | 2011-09-29 18:03:39 +0300 |
---|---|---|
committer | Paul ProductEngine <pguslisty@productengine.com> | 2011-09-29 18:03:39 +0300 |
commit | 6a463a41fec89c7f1eadb77c16eeae169ff777d0 (patch) | |
tree | f297c32418eb139eded752ce99b418773328e458 /indra/llcommon/llsingleton.h | |
parent | c44db34a15abd2e96b8fd461e9fb3e217fe648cc (diff) | |
parent | 71ed326f51770b215ba5dd2ac8d159c3b764c2d2 (diff) |
Merge sergeylproductengine/viewer-experience-fui with richard/viewer-experience-fui
Diffstat (limited to 'indra/llcommon/llsingleton.h')
-rw-r--r-- | indra/llcommon/llsingleton.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 00757be277..49d99f2cd0 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -114,8 +114,7 @@ private: ~SingletonInstanceData() { - SingletonInstanceData& data = getData(); - if (data.mInitState != DELETED) + if (mInitState != DELETED) { deleteSingleton(); } @@ -130,7 +129,26 @@ public: data.mInitState = DELETED; } - // Can be used to control when the singleton is deleted. Not normally needed. + /** + * @brief Immediately delete the singleton. + * + * A subsequent call to LLProxy::getInstance() will construct a new + * instance of the class. + * + * LLSingletons are normally destroyed after main() has exited and the C++ + * runtime is cleaning up statically-constructed objects. Some classes + * derived from LLSingleton have objects that are part of a runtime system + * that is terminated before main() exits. Calling the destructor of those + * objects after the termination of their respective systems can cause + * crashes and other problems during termination of the project. Using this + * method to destroy the singleton early can prevent these crashes. + * + * An example where this is needed is for a LLSingleton that has an APR + * object as a member that makes APR calls on destruction. The APR system is + * shut down explicitly before main() exits. This causes a crash on exit. + * Using this method before the call to apr_terminate() and NOT calling + * getInstance() again will prevent the crash. + */ static void deleteSingleton() { delete getData().mSingletonInstance; |