From 87ba85eaabbfd5fd7ad8ca8136f4783b1d932264 Mon Sep 17 00:00:00 2001
From: simon <none@none>
Date: Wed, 24 Apr 2013 09:35:38 -0700
Subject: [PATCH] =?UTF-8?q?=C3=AF=C2=BB=C2=BFdiff=20-r=2059c7bed66dfd=20in?=
 =?UTF-8?q?dra/llcommon/lleventapi.h?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 indra/llcommon/lleventapi.h                   |  4 +-
 indra/llcommon/lleventtimer.h                 |  2 +-
 indra/llcommon/llfasttimer.cpp                |  8 +--
 indra/llcommon/llfasttimer.h                  |  4 +-
 indra/llcommon/llinstancetracker.cpp          | 22 -------
 indra/llcommon/llinstancetracker.h            | 58 +++---------------
 indra/llcommon/llleap.h                       |  2 +-
 indra/llcommon/llsingleton.cpp                |  1 -
 indra/llcommon/llsingleton.h                  | 60 ++++---------------
 .../llcommon/tests/llinstancetracker_test.cpp |  6 +-
 indra/llrender/llgl.h                         |  4 +-
 indra/llui/llconsole.h                        |  2 +-
 indra/llui/llfloater.h                        |  2 +-
 indra/llui/lllayoutstack.h                    |  2 +-
 indra/llui/llnotifications.cpp                |  4 +-
 indra/llui/llnotifications.h                  |  6 +-
 indra/llwindow/llwindow.h                     |  2 +-
 indra/llxml/llcontrol.cpp                     |  2 +-
 indra/llxml/llcontrol.h                       | 10 ++--
 indra/newview/llfloaterwebcontent.cpp         |  2 +-
 indra/newview/llfloaterwebcontent.h           |  4 +-
 indra/newview/llmediactrl.cpp                 |  2 +-
 indra/newview/llmediactrl.h                   |  2 +-
 indra/newview/llnamelistctrl.h                |  2 +-
 indra/newview/lltoast.cpp                     |  3 +-
 indra/newview/lltoast.h                       |  2 +-
 indra/newview/lltoastnotifypanel.cpp          |  2 +-
 indra/newview/lltoastnotifypanel.h            |  2 +-
 indra/newview/lltoolselect.h                  |  2 +-
 indra/newview/tests/llagentaccess_test.cpp    |  2 +-
 indra/newview/tests/lllogininstance_test.cpp  |  2 +-
 .../tests/llremoteparcelrequest_test.cpp      |  2 +-
 indra/newview/tests/llsecapi_test.cpp         |  2 +-
 .../newview/tests/llsechandler_basic_test.cpp |  2 +-
 indra/newview/tests/llslurl_test.cpp          |  2 +-
 indra/newview/tests/lltranslate_test.cpp      |  2 +-
 indra/newview/tests/llviewerhelputil_test.cpp |  2 +-
 indra/newview/tests/llviewernetwork_test.cpp  |  2 +-
 indra/newview/tests/llworldmipmap_test.cpp    |  2 +-
 39 files changed, 68 insertions(+), 176 deletions(-)

diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h
index 10c7e7a23f..5991fe8fd5 100644
--- a/indra/llcommon/lleventapi.h
+++ b/indra/llcommon/lleventapi.h
@@ -41,10 +41,10 @@
  * Deriving from LLInstanceTracker lets us enumerate instances.
  */
 class LL_COMMON_API LLEventAPI: public LLDispatchListener,
-                  public INSTANCE_TRACKER_KEYED(LLEventAPI, std::string)
+                  public LLInstanceTracker<LLEventAPI, std::string>
 {
     typedef LLDispatchListener lbase;
-    typedef INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) ibase;
+    typedef LLInstanceTracker<LLEventAPI, std::string> ibase;
 
 public:
 
diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h
index e55f851758..dc918121e1 100644
--- a/indra/llcommon/lleventtimer.h
+++ b/indra/llcommon/lleventtimer.h
@@ -33,7 +33,7 @@
 #include "lltimer.h"
 
 // class for scheduling a function to be called at a given frequency (approximate, inprecise)
-class LL_COMMON_API LLEventTimer : public INSTANCE_TRACKER(LLEventTimer)
+class LL_COMMON_API LLEventTimer : public LLInstanceTracker<LLEventTimer>
 {
 public:
 
diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp
index 9b15804e97..51a9441cd5 100644
--- a/indra/llcommon/llfasttimer.cpp
+++ b/indra/llcommon/llfasttimer.cpp
@@ -107,17 +107,13 @@ class NamedTimerFactory : public LLSingleton<NamedTimerFactory>
 {
 public:
 	NamedTimerFactory()
-	:	mTimerRoot(NULL)
-	{}
-
-	/*virtual */ void initSingleton()
+	:	mTimerRoot(new LLFastTimer::NamedTimer("root"))
 	{
-		mTimerRoot = new LLFastTimer::NamedTimer("root");
 		mRootFrameState.setNamedTimer(mTimerRoot);
 		mTimerRoot->setFrameState(&mRootFrameState);
 		mTimerRoot->mParent = mTimerRoot;
 		mTimerRoot->setCollapsed(false);
-		mRootFrameState.mParent = &mRootFrameState;
+		mRootFrameState.mParent = &mRootFrameState;	
 	}
 
 	~NamedTimerFactory()
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index a6b34bdc69..a99a1d88af 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -63,7 +63,7 @@ public:
 
 	// stores a "named" timer instance to be reused via multiple LLFastTimer stack instances
 	class LL_COMMON_API NamedTimer
-	:	public LLInstanceTracker<NamedTimer, InstanceTrackType_NamedTimer >
+	:	public LLInstanceTracker<NamedTimer>
 	{
 		friend class DeclareTimer;
 	public:
@@ -139,7 +139,7 @@ public:
 
 	// used to statically declare a new named timer
 	class LL_COMMON_API DeclareTimer
-	:	public LLInstanceTracker< DeclareTimer, InstanceTrackType_DeclareTimer >
+	:	public LLInstanceTracker< DeclareTimer >
 	{
 		friend class LLFastTimer;
 	public:
diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp
index 89430f82d7..247d0dc4fb 100644
--- a/indra/llcommon/llinstancetracker.cpp
+++ b/indra/llcommon/llinstancetracker.cpp
@@ -32,26 +32,4 @@
 // external library headers
 // other Linden headers
 
-static bool sInstanceTrackerData_initialized = false;
-static void* sInstanceTrackerData[ kInstanceTrackTypeCount ];
-
-
-void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t)
-{
-	// std::map::insert() is just what we want here. You attempt to insert a
-	// (key, value) pair. If the specified key doesn't yet exist, it inserts
-	// the pair and returns a std::pair of (iterator, true). If the specified
-	// key DOES exist, insert() simply returns (iterator, false). One lookup
-	// handles both cases.
-	if (!sInstanceTrackerData_initialized)
-	{
-		for (S32 i = 0; i < (S32) kInstanceTrackTypeCount; i++)
-		{
-			sInstanceTrackerData[i] = NULL;
-		}
-		sInstanceTrackerData_initialized = true;
-	}
-
-	return sInstanceTrackerData[t];
-}
 
diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h
index b290526754..361182380a 100644
--- a/indra/llcommon/llinstancetracker.h
+++ b/indra/llcommon/llinstancetracker.h
@@ -38,33 +38,6 @@
 #include <boost/iterator/transform_iterator.hpp>
 #include <boost/iterator/indirect_iterator.hpp>
 
-enum InstanceTrackType
-{
-	InstanceTrackType_LLEventAPI,
-	InstanceTrackType_LLEventTimer,
-	InstanceTrackType_NamedTimer,
-	InstanceTrackType_DeclareTimer,
-	InstanceTrackType_LLLeap,
-	InstanceTrackType_LLGLNamePool,
-	InstanceTrackType_LLConsole,
-	InstanceTrackType_LLFloater,
-	InstanceTrackType_LLFloaterWebContent,
-	InstanceTrackType_LLLayoutStack,
-	InstanceTrackType_LLNotificationContext,
-	InstanceTrackType_LLWindow,
-	InstanceTrackType_LLControlGroup,
-	InstanceTrackType_LLControlCache,
-	InstanceTrackType_LLMediaCtrl,
-	InstanceTrackType_LLNameListCtrl,
-	InstanceTrackType_LLToast,
-	InstanceTrackType_Keyed,	// for integ tests
-	InstanceTrackType_Unkeyed,	// for integ tests
-	kInstanceTrackTypeCount
-};
-
-#define INSTANCE_TRACKER(T)			LLInstanceTracker< T, InstanceTrackType_##T >
-#define INSTANCE_TRACKER_KEYED(T,K)	LLInstanceTracker< T, InstanceTrackType_##T, K >
-
 /**
  * Base class manages "class-static" data that must actually have singleton
  * semantics: one instance per process, rather than one instance per module as
@@ -73,22 +46,7 @@ enum InstanceTrackType
 class LL_COMMON_API LLInstanceTrackerBase
 {
 protected:
-	/// Get a process-unique void* pointer slot for the specified type_info
-	//static void * & getInstances(std::type_info const & info);
-	static void * & getInstances(InstanceTrackType t);
-
-	/// Find or create a STATICDATA instance for the specified TRACKED class.
-	/// STATICDATA must be default-constructible.
-	template<typename STATICDATA, class TRACKED, class INST, InstanceTrackType TRACKEDTYPE>
-	static STATICDATA& getStatic()
-	{
-		void *& instances = getInstances(TRACKEDTYPE);
-		if (! instances)
-		{
-			instances = new STATICDATA;
-		}
-		return *static_cast<STATICDATA*>(instances);
-	}
+
 
     /// It's not essential to derive your STATICDATA (for use with
     /// getStatic()) from StaticBase; it's just that both known
@@ -108,16 +66,16 @@ LL_COMMON_API void assert_main_thread();
 /// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup
 /// If KEY is not provided, then instances are stored in a simple set
 /// @NOTE: see explicit specialization below for default KEY==T* case
-template<typename T, enum InstanceTrackType TRACKED, typename KEY = T*>
+template<typename T, typename KEY = T*>
 class LLInstanceTracker : public LLInstanceTrackerBase
 {
-	typedef LLInstanceTracker<T, TRACKED, KEY> MyT;
+	typedef LLInstanceTracker<T, KEY> self_t;
 	typedef typename std::map<KEY, T*> InstanceMap;
 	struct StaticData: public StaticBase
 	{
 		InstanceMap sMap;
 	};
-	static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT, T, TRACKED>(); }
+	static StaticData& getStatic() { static StaticData sData; return sData;}
 	static InstanceMap& getMap_() 
 	{
 		// assert_main_thread();   fwiw this class is not thread safe, and it used by multiple threads.  Bad things happen.
@@ -263,16 +221,16 @@ private:
 
 /// explicit specialization for default case where KEY is T*
 /// use a simple std::set<T*>
-template<typename T, enum InstanceTrackType TRACKED>
-class LLInstanceTracker<T, TRACKED, T*> : public LLInstanceTrackerBase
+template<typename T>
+class LLInstanceTracker<T, T*> : public LLInstanceTrackerBase
 {
-	typedef LLInstanceTracker<T, TRACKED, T*> MyT;
+	typedef LLInstanceTracker<T, T*> self_t;
 	typedef typename std::set<T*> InstanceSet;
 	struct StaticData: public StaticBase
 	{
 		InstanceSet sSet;
 	};
-	static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT, T, TRACKED>(); }
+	static StaticData& getStatic() { static StaticData sData; return sData; }
 	static InstanceSet& getSet_() { return getStatic().sSet; }
 
 public:
diff --git a/indra/llcommon/llleap.h b/indra/llcommon/llleap.h
index d4e138f4be..e33f25e530 100644
--- a/indra/llcommon/llleap.h
+++ b/indra/llcommon/llleap.h
@@ -29,7 +29,7 @@
  * LLLeap* pointer should be validated before use by
  * LLLeap::getInstance(LLLeap*) (see LLInstanceTracker).
  */
-class LL_COMMON_API LLLeap: public INSTANCE_TRACKER(LLLeap)
+class LL_COMMON_API LLLeap: public LLInstanceTracker<LLLeap>
 {
 public:
 
diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp
index eb8e2c9456..9b49e52377 100644
--- a/indra/llcommon/llsingleton.cpp
+++ b/indra/llcommon/llsingleton.cpp
@@ -28,5 +28,4 @@
 
 #include "llsingleton.h"
 
-std::map<std::string, void *> * LLSingletonRegistry::sSingletonMap = NULL;
 
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 49d99f2cd0..84afeb563e 100644
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -30,38 +30,6 @@
 #include <typeinfo>
 #include <boost/noncopyable.hpp>
 
-/// @brief A global registry of all singletons to prevent duplicate allocations
-/// across shared library boundaries
-class LL_COMMON_API LLSingletonRegistry {
-	private:
-		typedef std::map<std::string, void *> TypeMap;
-		static TypeMap * sSingletonMap;
-
-		static void checkInit()
-		{
-			if(sSingletonMap == NULL)
-			{
-				sSingletonMap = new TypeMap();
-			}
-		}
-
-	public:
-		template<typename T> static void * & get()
-		{
-			std::string name(typeid(T).name());
-
-			checkInit();
-
-			// the first entry of the pair returned by insert will be either the existing
-			// iterator matching our key, or the newly inserted NULL initialized entry
-			// see "Insert element" in http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html
-			TypeMap::iterator result =
-				sSingletonMap->insert(std::make_pair(name, (void*)NULL)).first;
-
-			return result->second;
-		}
-};
-
 // LLSingleton implements the getInstance() method part of the Singleton
 // pattern. It can't make the derived class constructors protected, though, so
 // you have to do that yourself.
@@ -93,7 +61,6 @@ class LLSingleton : private boost::noncopyable
 private:
 	typedef enum e_init_state
 	{
-		UNINITIALIZED,
 		CONSTRUCTING,
 		INITIALIZING,
 		INITIALIZED,
@@ -109,8 +76,11 @@ private:
 		
 		SingletonInstanceData()
 		:	mSingletonInstance(NULL),
-			mInitState(UNINITIALIZED)
-		{}
+			mInitState(CONSTRUCTING)
+		{
+			mSingletonInstance = new DERIVED_TYPE(); 
+			mInitState = INITIALIZING;
+		}
 
 		~SingletonInstanceData()
 		{
@@ -159,16 +129,8 @@ public:
 	static SingletonInstanceData& getData()
 	{
 		// this is static to cache the lookup results
-		static void * & registry = LLSingletonRegistry::get<DERIVED_TYPE>();
-
-		// *TODO - look into making this threadsafe
-		if(NULL == registry)
-		{
-			static SingletonInstanceData data;
-			registry = &data;
-		}
-
-		return *static_cast<SingletonInstanceData *>(registry);
+		static SingletonInstanceData sData;
+		return sData;
 	}
 
 	static DERIVED_TYPE* getInstance()
@@ -185,13 +147,11 @@ public:
 			llwarns << "Trying to access deleted singleton " << typeid(DERIVED_TYPE).name() << " creating new instance" << llendl;
 		}
 		
-		if (!data.mSingletonInstance) 
+		if (data.mInitState == INITIALIZING) 
 		{
-			data.mInitState = CONSTRUCTING;
-			data.mSingletonInstance = new DERIVED_TYPE(); 
-			data.mInitState = INITIALIZING;
+			// go ahead and flag ourselves as initialized so we can be reentrant during initialization
+			data.mInitState = INITIALIZED;
 			data.mSingletonInstance->initSingleton(); 
-			data.mInitState = INITIALIZED;	
 		}
 		
 		return data.mSingletonInstance;
diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp
index b2d82d1843..e769c3e22c 100644
--- a/indra/llcommon/tests/llinstancetracker_test.cpp
+++ b/indra/llcommon/tests/llinstancetracker_test.cpp
@@ -48,16 +48,16 @@ struct Badness: public std::runtime_error
     Badness(const std::string& what): std::runtime_error(what) {}
 };
 
-struct Keyed: public INSTANCE_TRACKER_KEYED(Keyed, std::string)
+struct Keyed: public LLInstanceTracker<Keyed, std::string>
 {
     Keyed(const std::string& name):
-        INSTANCE_TRACKER_KEYED(Keyed, std::string)(name),
+        LLInstanceTracker<Keyed, std::string>(name),
         mName(name)
     {}
     std::string mName;
 };
 
-struct Unkeyed: public INSTANCE_TRACKER(Unkeyed)
+struct Unkeyed: public LLInstanceTracker<Unkeyed>
 {
     Unkeyed(const std::string& thrw="")
     {
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index 133c2de1f5..823de9d361 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -350,10 +350,10 @@ public:
 	Generic pooling scheme for things which use GL names (used for occlusion queries and vertex buffer objects).
 	Prevents thrashing of GL name caches by avoiding calls to glGenFoo and glDeleteFoo.
 */
-class LLGLNamePool : public INSTANCE_TRACKER(LLGLNamePool)
+class LLGLNamePool : public LLInstanceTracker<LLGLNamePool>
 {
 public:
-	typedef INSTANCE_TRACKER(LLGLNamePool) tracker_t;
+	typedef LLInstanceTracker<LLGLNamePool> tracker_t;
 
 	struct NameEntry
 	{
diff --git a/indra/llui/llconsole.h b/indra/llui/llconsole.h
index b264aeb7eb..5ff05698b0 100644
--- a/indra/llui/llconsole.h
+++ b/indra/llui/llconsole.h
@@ -34,7 +34,7 @@
 
 class LLSD;
 
-class LLConsole : public LLFixedBuffer, public LLUICtrl, public INSTANCE_TRACKER(LLConsole)
+class LLConsole : public LLFixedBuffer, public LLUICtrl, public LLInstanceTracker<LLConsole>
 {
 public:
 
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index f28ceb0ce4..99d1d2614d 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -116,7 +116,7 @@ struct LLCoordFloater : LLCoord<LL_COORD_FLOATER>
 	
 };
 
-class LLFloater : public LLPanel, public INSTANCE_TRACKER(LLFloater)
+class LLFloater : public LLPanel, public LLInstanceTracker<LLFloater>
 {
 	friend class LLFloaterView;
 	friend class LLFloaterReg;
diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h
index a8b5466242..8e330278af 100644
--- a/indra/llui/lllayoutstack.h
+++ b/indra/llui/lllayoutstack.h
@@ -35,7 +35,7 @@
 class LLLayoutPanel;
 
 
-class LLLayoutStack : public LLView, public INSTANCE_TRACKER(LLLayoutStack)
+class LLLayoutStack : public LLView, public LLInstanceTracker<LLLayoutStack>
 {
 public:
 
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index 8bafbd53d8..1789f003b9 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -1121,7 +1121,7 @@ bool LLNotificationChannelBase::updateItem(const LLSD& payload, LLNotificationPt
 
 LLNotificationChannel::LLNotificationChannel(const Params& p)
 :	LLNotificationChannelBase(p.filter()),
-	LLInstanceTracker<LLNotificationChannel, InstanceTrackType_LLNotificationContext, std::string>(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString()),
+	LLInstanceTracker<LLNotificationChannel, std::string>(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString()),
 	mName(p.name.isProvided() ? p.name : LLUUID::generateNewID().asString())
 {
 	BOOST_FOREACH(const std::string& source, p.sources)
@@ -1135,7 +1135,7 @@ LLNotificationChannel::LLNotificationChannel(const std::string& name,
 											 const std::string& parent,
 											 LLNotificationFilter filter) 
 :	LLNotificationChannelBase(filter),
-	LLInstanceTracker<LLNotificationChannel, InstanceTrackType_LLNotificationContext, std::string>(name),
+	LLInstanceTracker<LLNotificationChannel, std::string>(name),
 	mName(name)
 {
 	// bind to notification broadcast
diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h
index 2561125aa5..cd3728305e 100644
--- a/indra/llui/llnotifications.h
+++ b/indra/llui/llnotifications.h
@@ -135,11 +135,11 @@ typedef LLFunctorRegistration<LLNotificationResponder> LLNotificationFunctorRegi
 
 // context data that can be looked up via a notification's payload by the display logic
 // derive from this class to implement specific contexts
-class LLNotificationContext : public INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID)
+class LLNotificationContext : public LLInstanceTracker<LLNotificationContext, LLUUID>
 {
 public:
 
-	LLNotificationContext() : INSTANCE_TRACKER_KEYED(LLNotificationContext, LLUUID)(LLUUID::generateNewID())
+	LLNotificationContext() : LLInstanceTracker<LLNotificationContext, LLUUID>(LLUUID::generateNewID())
 	{
 	}
 
@@ -815,7 +815,7 @@ typedef boost::intrusive_ptr<LLNotificationChannel> LLNotificationChannelPtr;
 class LLNotificationChannel : 
 	boost::noncopyable, 
 	public LLNotificationChannelBase,
-	public LLInstanceTracker<LLNotificationChannel, InstanceTrackType_LLNotificationContext, std::string>
+	public LLInstanceTracker<LLNotificationChannel, std::string>
 {
 	LOG_CLASS(LLNotificationChannel);
 
diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h
index 06d7e4907a..78186004b8 100644
--- a/indra/llwindow/llwindow.h
+++ b/indra/llwindow/llwindow.h
@@ -39,7 +39,7 @@ class LLWindowCallbacks;
 
 // Refer to llwindow_test in test/common/llwindow for usage example
 
-class LLWindow : public INSTANCE_TRACKER(LLWindow)
+class LLWindow : public LLInstanceTracker<LLWindow>
 {
 public:
 
diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp
index f82750af47..666c03e9ff 100644
--- a/indra/llxml/llcontrol.cpp
+++ b/indra/llxml/llcontrol.cpp
@@ -316,7 +316,7 @@ LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name)
 ////////////////////////////////////////////////////////////////////////////
 
 LLControlGroup::LLControlGroup(const std::string& name)
-:	INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name)
+:	LLInstanceTracker<LLControlGroup, std::string>(name)
 {
 	mTypeString[TYPE_U32] = "U32";
 	mTypeString[TYPE_S32] = "S32";
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index 6ea010f4f9..ee7d1d50b7 100644
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -180,7 +180,7 @@ T convert_from_llsd(const LLSD& sd, eControlType type, const std::string& contro
 }
 
 //const U32 STRING_CACHE_SIZE = 10000;
-class LLControlGroup : public INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)
+class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string>
 {
 	LOG_CLASS(LLControlGroup);
 
@@ -197,7 +197,7 @@ public:
 	~LLControlGroup();
 	void cleanup();
 	
-	typedef INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)::instance_iter instance_iter;
+	typedef LLInstanceTracker<LLControlGroup, std::string>::instance_iter instance_iter;
 
 	LLControlVariablePtr getControl(const std::string& name);
 
@@ -306,7 +306,7 @@ public:
 //! without have to manually create and bind a listener to a local
 //! object.
 template <class T>
-class LLControlCache : public LLRefCount, public LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string>
+class LLControlCache : public LLRefCount, public LLInstanceTracker<LLControlCache<T>, std::string>
 {
 public:
 	// This constructor will declare a control if it doesn't exist in the contol group
@@ -314,7 +314,7 @@ public:
 					const std::string& name, 
 					const T& default_value, 
 					const std::string& comment)
-	:	LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string >(name)
+	:	LLInstanceTracker<LLControlCache<T>, std::string >(name)
 	{
 		if(!group.controlExists(name))
 		{
@@ -329,7 +329,7 @@ public:
 
 	LLControlCache(LLControlGroup& group,
 					const std::string& name)
-	:	LLInstanceTracker<LLControlCache<T>, InstanceTrackType_LLControlCache, std::string >(name)
+	:	LLInstanceTracker<LLControlCache<T>, std::string >(name)
 	{
 		if(!group.controlExists(name))
 		{
diff --git a/indra/newview/llfloaterwebcontent.cpp b/indra/newview/llfloaterwebcontent.cpp
index 94c3f4149c..3fe2518de6 100644
--- a/indra/newview/llfloaterwebcontent.cpp
+++ b/indra/newview/llfloaterwebcontent.cpp
@@ -54,7 +54,7 @@ LLFloaterWebContent::_Params::_Params()
 
 LLFloaterWebContent::LLFloaterWebContent( const Params& params )
 :	LLFloater( params ),
-	INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string)(params.id()),
+	LLInstanceTracker<LLFloaterWebContent, std::string>(params.id()),
 	mWebBrowser(NULL),
 	mAddressCombo(NULL),
 	mSecureLockIcon(NULL),
diff --git a/indra/newview/llfloaterwebcontent.h b/indra/newview/llfloaterwebcontent.h
index 409c15fb0b..86b5a5e00b 100644
--- a/indra/newview/llfloaterwebcontent.h
+++ b/indra/newview/llfloaterwebcontent.h
@@ -40,11 +40,11 @@ class LLIconCtrl;
 class LLFloaterWebContent :
 	public LLFloater,
 	public LLViewerMediaObserver,
-	public INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string)
+	public LLInstanceTracker<LLFloaterWebContent, std::string>
 {
 public:
 
-	typedef INSTANCE_TRACKER_KEYED(LLFloaterWebContent, std::string) instance_tracker_t;
+	typedef LLInstanceTracker<LLFloaterWebContent, std::string> instance_tracker_t;
     LOG_CLASS(LLFloaterWebContent);
 
 	struct _Params : public LLInitParam::Block<_Params>
diff --git a/indra/newview/llmediactrl.cpp b/indra/newview/llmediactrl.cpp
index 6362165c77..2075aeed63 100644
--- a/indra/newview/llmediactrl.cpp
+++ b/indra/newview/llmediactrl.cpp
@@ -81,7 +81,7 @@ LLMediaCtrl::Params::Params()
 
 LLMediaCtrl::LLMediaCtrl( const Params& p) :
 	LLPanel( p ),
-	INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID)(LLUUID::generateNewID()),
+	LLInstanceTracker<LLMediaCtrl, LLUUID>(LLUUID::generateNewID()),
 	mTextureDepthBytes( 4 ),
 	mBorder(NULL),
 	mFrequentUpdates( true ),
diff --git a/indra/newview/llmediactrl.h b/indra/newview/llmediactrl.h
index 4fed21bf22..6c38c1fb56 100644
--- a/indra/newview/llmediactrl.h
+++ b/indra/newview/llmediactrl.h
@@ -42,7 +42,7 @@ class LLMediaCtrl :
 	public LLPanel,
 	public LLViewerMediaObserver,
 	public LLViewerMediaEventEmitter,
-	public INSTANCE_TRACKER_KEYED(LLMediaCtrl, LLUUID)
+	public LLInstanceTracker<LLMediaCtrl, LLUUID>
 {
 	LOG_CLASS(LLMediaCtrl);
 public:
diff --git a/indra/newview/llnamelistctrl.h b/indra/newview/llnamelistctrl.h
index d82727f018..92e82b672d 100644
--- a/indra/newview/llnamelistctrl.h
+++ b/indra/newview/llnamelistctrl.h
@@ -64,7 +64,7 @@ private:
 
 
 class LLNameListCtrl
-:	public LLScrollListCtrl, public INSTANCE_TRACKER(LLNameListCtrl)
+:	public LLScrollListCtrl, public LLInstanceTracker<LLNameListCtrl>
 {
 public:
 
diff --git a/indra/newview/lltoast.cpp b/indra/newview/lltoast.cpp
index 49debe67f6..a26e47e1c8 100644
--- a/indra/newview/lltoast.cpp
+++ b/indra/newview/lltoast.cpp
@@ -572,7 +572,8 @@ S32	LLToast::notifyParent(const LLSD& info)
 //static
 void LLToast::updateClass()
 {
-	for (INSTANCE_TRACKER(LLToast)::instance_iter iter = INSTANCE_TRACKER(LLToast)::beginInstances(); iter != INSTANCE_TRACKER(LLToast)::endInstances(); ) 
+	for (LLInstanceTracker<LLToast>::instance_iter iter = LLInstanceTracker<LLToast>::beginInstances(); 
+			iter != LLInstanceTracker<LLToast>::endInstances(); ) 
 	{
 		LLToast& toast = *iter++;
 		
diff --git a/indra/newview/lltoast.h b/indra/newview/lltoast.h
index 718b464977..5da7120e84 100644
--- a/indra/newview/lltoast.h
+++ b/indra/newview/lltoast.h
@@ -69,7 +69,7 @@ private :
  * Represents toast pop-up.
  * This is a parent view for all toast panels.
  */
-class LLToast : public LLModalDialog, public INSTANCE_TRACKER(LLToast)
+class LLToast : public LLModalDialog, public LLInstanceTracker<LLToast>
 {
 	friend class LLToastLifeTimer;
 public:
diff --git a/indra/newview/lltoastnotifypanel.cpp b/indra/newview/lltoastnotifypanel.cpp
index 9b5ccc0150..94d07b37ef 100644
--- a/indra/newview/lltoastnotifypanel.cpp
+++ b/indra/newview/lltoastnotifypanel.cpp
@@ -57,7 +57,7 @@ LLToastNotifyPanel::button_click_signal_t LLToastNotifyPanel::sButtonClickSignal
 
 LLToastNotifyPanel::LLToastNotifyPanel(const LLNotificationPtr& notification, const LLRect& rect, bool show_images) 
 :	LLToastPanel(notification),
-	LLInstanceTracker<LLToastNotifyPanel, InstanceTrackType_LLToast, LLUUID>(notification->getID())
+	LLInstanceTracker<LLToastNotifyPanel, LLUUID>(notification->getID())
 {
 	init(rect, show_images);
 }
diff --git a/indra/newview/lltoastnotifypanel.h b/indra/newview/lltoastnotifypanel.h
index 5de75a7a9f..d02171b512 100644
--- a/indra/newview/lltoastnotifypanel.h
+++ b/indra/newview/lltoastnotifypanel.h
@@ -47,7 +47,7 @@ class LLNotificationForm;
  * @deprecated this class will be removed after all toast panel types are
  *  implemented in separate classes.
  */
-class LLToastNotifyPanel: public LLToastPanel, public LLInstanceTracker<LLToastNotifyPanel, InstanceTrackType_LLToast, LLUUID>
+class LLToastNotifyPanel: public LLToastPanel, public LLInstanceTracker<LLToastNotifyPanel, LLUUID>
 {
 public:
 	/**
diff --git a/indra/newview/lltoolselect.h b/indra/newview/lltoolselect.h
index baa27f6071..74dababe8c 100644
--- a/indra/newview/lltoolselect.h
+++ b/indra/newview/lltoolselect.h
@@ -34,7 +34,7 @@
 
 class LLObjectSelection;
 
-class LLToolSelect : public LLTool, public LLSingleton<LLToolSelect>
+class LLToolSelect : public LLTool
 {
 public:
 	LLToolSelect( LLToolComposite* composite );
diff --git a/indra/newview/tests/llagentaccess_test.cpp b/indra/newview/tests/llagentaccess_test.cpp
index 426ad40342..05289f0309 100644
--- a/indra/newview/tests/llagentaccess_test.cpp
+++ b/indra/newview/tests/llagentaccess_test.cpp
@@ -40,7 +40,7 @@
 static U32 test_preferred_maturity = SIM_ACCESS_PG;
 
 LLControlGroup::LLControlGroup(const std::string& name)
-	: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name)
+:	LLInstanceTracker<LLControlGroup, std::string>(name)
 {
 }
 
diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp
index 25da5939f1..7705b4c567 100644
--- a/indra/newview/tests/lllogininstance_test.cpp
+++ b/indra/newview/tests/lllogininstance_test.cpp
@@ -167,7 +167,7 @@ std::string LLGridManager::getAppSLURLBase(const std::string& grid_name)
 LLControlGroup gSavedSettings("Global");
 
 LLControlGroup::LLControlGroup(const std::string& name) :
-	INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name){}
+	LLInstanceTracker<LLControlGroup, std::string>(name){}
 LLControlGroup::~LLControlGroup() {}
 void LLControlGroup::setBOOL(const std::string& name, BOOL val) {}
 BOOL LLControlGroup::getBOOL(const std::string& name) { return FALSE; }
diff --git a/indra/newview/tests/llremoteparcelrequest_test.cpp b/indra/newview/tests/llremoteparcelrequest_test.cpp
index da273132db..ed66066b0a 100644
--- a/indra/newview/tests/llremoteparcelrequest_test.cpp
+++ b/indra/newview/tests/llremoteparcelrequest_test.cpp
@@ -69,7 +69,7 @@ void LLAgent::sendReliableMessage(void) { }
 LLUUID gAgentSessionID;
 LLUUID gAgentID;
 LLUIColor::LLUIColor(void) { }
-LLControlGroup::LLControlGroup(std::string const & name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { }
+LLControlGroup::LLControlGroup(std::string const & name) : LLInstanceTracker<LLControlGroup, std::string>(name) { }
 LLControlGroup::~LLControlGroup(void) { }
 void LLUrlEntryParcel::processParcelInfo(const LLUrlEntryParcel::LLParcelData& parcel_data) { }
 
diff --git a/indra/newview/tests/llsecapi_test.cpp b/indra/newview/tests/llsecapi_test.cpp
index 83a4149971..703603e2db 100644
--- a/indra/newview/tests/llsecapi_test.cpp
+++ b/indra/newview/tests/llsecapi_test.cpp
@@ -37,7 +37,7 @@
 // Mock objects for the dependencies of the code we're testing                               
 
 LLControlGroup::LLControlGroup(const std::string& name)
-: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {}
+: LLInstanceTracker<LLControlGroup, std::string>(name) {}
 LLControlGroup::~LLControlGroup() {}
 BOOL LLControlGroup::declareString(const std::string& name,
                                    const std::string& initial_val,
diff --git a/indra/newview/tests/llsechandler_basic_test.cpp b/indra/newview/tests/llsechandler_basic_test.cpp
index 814010028f..0235400976 100644
--- a/indra/newview/tests/llsechandler_basic_test.cpp
+++ b/indra/newview/tests/llsechandler_basic_test.cpp
@@ -69,7 +69,7 @@ extern bool _cert_hostname_wildcard_match(const std::string& hostname, const std
 std::string gFirstName;
 std::string gLastName;
 LLControlGroup::LLControlGroup(const std::string& name)
-: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {}
+: LLInstanceTracker<LLControlGroup, std::string>(name) {}
 LLControlGroup::~LLControlGroup() {}
 BOOL LLControlGroup::declareString(const std::string& name,
                                    const std::string& initial_val,
diff --git a/indra/newview/tests/llslurl_test.cpp b/indra/newview/tests/llslurl_test.cpp
index d7debd6c67..09343ef227 100644
--- a/indra/newview/tests/llslurl_test.cpp
+++ b/indra/newview/tests/llslurl_test.cpp
@@ -35,7 +35,7 @@
 // Mock objects for the dependencies of the code we're testing
 
 LLControlGroup::LLControlGroup(const std::string& name)
-: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {}
+: LLInstanceTracker<LLControlGroup, std::string>(name) {}
 LLControlGroup::~LLControlGroup() {}
 BOOL LLControlGroup::declareString(const std::string& name,
                                    const std::string& initial_val,
diff --git a/indra/newview/tests/lltranslate_test.cpp b/indra/newview/tests/lltranslate_test.cpp
index c13660332d..fd9527d631 100644
--- a/indra/newview/tests/lltranslate_test.cpp
+++ b/indra/newview/tests/lltranslate_test.cpp
@@ -295,7 +295,7 @@ LLControlGroup gSavedSettings("test");
 std::string LLUI::getLanguage() { return "en"; }
 std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { return "dummy"; }
 
-LLControlGroup::LLControlGroup(const std::string& name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {}
+LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker<LLControlGroup, std::string>(name) {}
 std::string LLControlGroup::getString(const std::string& name) { return "dummy"; }
 LLControlGroup::~LLControlGroup() {}
 
diff --git a/indra/newview/tests/llviewerhelputil_test.cpp b/indra/newview/tests/llviewerhelputil_test.cpp
index 102cad8852..710881d811 100644
--- a/indra/newview/tests/llviewerhelputil_test.cpp
+++ b/indra/newview/tests/llviewerhelputil_test.cpp
@@ -47,7 +47,7 @@ static std::string gOS;
 // Mock objects for the dependencies of the code we're testing
 
 LLControlGroup::LLControlGroup(const std::string& name)
-	: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {}
+	: LLInstanceTracker<LLControlGroup, std::string>(name) {}
 LLControlGroup::~LLControlGroup() {}
 BOOL LLControlGroup::declareString(const std::string& name,
 				   const std::string& initial_val,
diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp
index 725b5122fb..a1e97ea17e 100644
--- a/indra/newview/tests/llviewernetwork_test.cpp
+++ b/indra/newview/tests/llviewernetwork_test.cpp
@@ -35,7 +35,7 @@
 // Mock objects for the dependencies of the code we're testing
 
 LLControlGroup::LLControlGroup(const std::string& name)
-: INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) {}
+: LLInstanceTracker<LLControlGroup, std::string>(name) {}
 LLControlGroup::~LLControlGroup() {}
 BOOL LLControlGroup::declareString(const std::string& name,
                                    const std::string& initial_val,
diff --git a/indra/newview/tests/llworldmipmap_test.cpp b/indra/newview/tests/llworldmipmap_test.cpp
index a6a2f8d7b9..142d75bcfd 100644
--- a/indra/newview/tests/llworldmipmap_test.cpp
+++ b/indra/newview/tests/llworldmipmap_test.cpp
@@ -46,7 +46,7 @@ void LLGLTexture::setBoostLevel(S32 ) { }
 LLViewerFetchedTexture* LLViewerTextureManager::getFetchedTextureFromUrl(const std::string&, FTType, BOOL, LLGLTexture::EBoostLevel, S8, 
 																		 LLGLint, LLGLenum, const LLUUID& ) { return NULL; }
 
-LLControlGroup::LLControlGroup(const std::string& name) : INSTANCE_TRACKER_KEYED(LLControlGroup, std::string)(name) { }
+LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker<LLControlGroup, std::string>(name) { }
 LLControlGroup::~LLControlGroup() { }
 std::string LLControlGroup::getString(const std::string& ) { return std::string("test_url"); }
 LLControlGroup gSavedSettings("test_settings");
-- 
GitLab