From 331e932857e1156a68b6d39d3ea2d8c1f39ec7ae Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Fri, 22 May 2015 14:02:24 -0400
Subject: [PATCH] MAINT-5232: Clean up some dubious LLSingleton methods. Remove
 evil getIfExists() method, used by no one. Remove evil destroyed() method,
 used in exactly three places -- one of which is a test. Replace with equally
 evil instanceExists() method, which is used EVERYWHERE -- sigh.

---
 indra/llcommon/llregistry.h               |  2 +-
 indra/llcommon/llsingleton.h              | 18 +++---------------
 indra/llcommon/tests/llsingleton_test.cpp |  1 -
 indra/newview/llfloaterimcontainer.cpp    |  2 +-
 4 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/indra/llcommon/llregistry.h b/indra/llcommon/llregistry.h
index 29950c108db..fde729f8f93 100755
--- a/indra/llcommon/llregistry.h
+++ b/indra/llcommon/llregistry.h
@@ -269,7 +269,7 @@ class LLRegistrySingleton
 
 		~ScopedRegistrar()
 		{
-			if (!singleton_t::destroyed())
+			if (singleton_t::instanceExists())
 			{
 				popScope();
 			}
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 6e6291a1653..a4877eed1f6 100755
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -166,31 +166,19 @@ class LLSingleton : private boost::noncopyable
 		return NULL;
 	}
 
-	static DERIVED_TYPE* getIfExists()
-	{
-		return sData.mInstance;
-	}
-
 	// Reference version of getInstance()
 	// Preferred over getInstance() as it disallows checking for NULL
 	static DERIVED_TYPE& instance()
 	{
 		return *getInstance();
 	}
-	
-	// Has this singleton been created uet?
-	// Use this to avoid accessing singletons before the can safely be constructed
+
+	// Has this singleton been created yet?
+	// Use this to avoid accessing singletons before they can safely be constructed.
 	static bool instanceExists()
 	{
 		return sData.mInitState == INITIALIZED;
 	}
-	
-	// Has this singleton already been deleted?
-	// Use this to avoid accessing singletons from a static object's destructor
-	static bool destroyed()
-	{
-		return sData.mInitState == DELETED;
-	}
 
 private:
 
diff --git a/indra/llcommon/tests/llsingleton_test.cpp b/indra/llcommon/tests/llsingleton_test.cpp
index 385289aefef..bed436283a5 100755
--- a/indra/llcommon/tests/llsingleton_test.cpp
+++ b/indra/llcommon/tests/llsingleton_test.cpp
@@ -65,7 +65,6 @@ namespace tut
 
 		//Delete the instance
 		LLSingletonTest::deleteSingleton();
-		ensure(LLSingletonTest::destroyed());
 		ensure(!LLSingletonTest::instanceExists());
 
 		//Construct it again.
diff --git a/indra/newview/llfloaterimcontainer.cpp b/indra/newview/llfloaterimcontainer.cpp
index ab57e8c170a..cacd66aee9c 100755
--- a/indra/newview/llfloaterimcontainer.cpp
+++ b/indra/newview/llfloaterimcontainer.cpp
@@ -101,7 +101,7 @@ LLFloaterIMContainer::~LLFloaterIMContainer()
 	gSavedPerAccountSettings.setBOOL("ConversationsMessagePaneCollapsed", mMessagesPane->isCollapsed());
 	gSavedPerAccountSettings.setBOOL("ConversationsParticipantListCollapsed", !isParticipantListExpanded());
 
-	if (!LLSingleton<LLIMMgr>::destroyed())
+	if (LLIMMgr::instanceExists())
 	{
 		LLIMMgr::getInstance()->removeSessionObserver(this);
 	}
-- 
GitLab