From 833579b14b134dce8f378336b9cbcd40cfa72c5f Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 23 May 2015 13:34:34 -0400 Subject: MAINT-5232: Convert gMessageSystem != NULL to simple bool test. Now that gMessageSystem is an LLPounceable, we would either have to define comparisons to LLPounceable's held type or static_cast to literally compare to NULL. But since we already define operator bool(), that's the easy (and idiomatic) fix. --- indra/newview/llmutelist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmutelist.cpp') diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index 65ac11092c..681203ef4f 100755 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -152,7 +152,7 @@ LLMuteList* LLMuteList::getInstance() { // Register callbacks at the first time that we find that the message system has been created. static BOOL registered = FALSE; - if( !registered && gMessageSystem != NULL) + if( !registered && gMessageSystem) { registered = TRUE; // Register our various callbacks -- cgit v1.2.3 From 3fc39776dd7a347870a5005808c69f27413de424 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 27 May 2015 14:38:51 -0400 Subject: MAINT-5232: Remove dubious polling in LLMuteList::getInstance(). The LLMuteList singleton instance might be requested before gMessageSystem is constructed. LLMuteList wants to register a couple gMessageSystem callbacks. Since gMessageSystem is not (yet) itself an LLSingleton, LLMuteList's constructor can't just call it into existence. Until now, LLMuteList overrode LLSingleton's getInstance() method: every time getInstance() was called, the subclass override method would check whether gMessageSystem had been initialized, and if so, register its callbacks before forwarding the call to the base-class LLSingleton::getInstance() method. Change to use LLPounceable::callWhenReady() instead. This is the reason gMessageSystem was made an LLPounceable. --- indra/newview/llmutelist.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'indra/newview/llmutelist.cpp') diff --git a/indra/newview/llmutelist.cpp b/indra/newview/llmutelist.cpp index 681203ef4f..88bfefa8b8 100755 --- a/indra/newview/llmutelist.cpp +++ b/indra/newview/llmutelist.cpp @@ -47,6 +47,7 @@ #include "pipeline.h" #include +#include #include "lldispatcher.h" #include "llxfermanager.h" @@ -146,22 +147,6 @@ std::string LLMute::getDisplayType() const } } - -/* static */ -LLMuteList* LLMuteList::getInstance() -{ - // Register callbacks at the first time that we find that the message system has been created. - static BOOL registered = FALSE; - if( !registered && gMessageSystem) - { - registered = TRUE; - // Register our various callbacks - gMessageSystem->setHandlerFuncFast(_PREHASH_MuteListUpdate, processMuteListUpdate); - gMessageSystem->setHandlerFuncFast(_PREHASH_UseCachedMuteList, processUseCachedMuteList); - } - return LLSingleton::getInstance(); // Call the "base" implementation. -} - //----------------------------------------------------------------------------- // LLMuteList() //----------------------------------------------------------------------------- @@ -169,6 +154,18 @@ LLMuteList::LLMuteList() : mIsLoaded(FALSE) { gGenericDispatcher.addHandler("emptymutelist", &sDispatchEmptyMuteList); + + // Register our callbacks. We may be constructed before gMessageSystem, so + // use callWhenReady() to register them as soon as gMessageSystem becomes + // available. + // When using bind(), must be explicit about default arguments such as + // that last NULL. + gMessageSystem.callWhenReady(boost::bind(&LLMessageSystem::setHandlerFuncFast, _1, + _PREHASH_MuteListUpdate, processMuteListUpdate, + static_cast(NULL))); + gMessageSystem.callWhenReady(boost::bind(&LLMessageSystem::setHandlerFuncFast, _1, + _PREHASH_UseCachedMuteList, processUseCachedMuteList, + static_cast(NULL))); } //----------------------------------------------------------------------------- -- cgit v1.2.3