Skip to content
Snippets Groups Projects
Commit 3fc39776 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

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.
parent df55db4a
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include "pipeline.h" #include "pipeline.h"
#include <boost/tokenizer.hpp> #include <boost/tokenizer.hpp>
#include <boost/bind.hpp>
#include "lldispatcher.h" #include "lldispatcher.h"
#include "llxfermanager.h" #include "llxfermanager.h"
...@@ -146,22 +147,6 @@ std::string LLMute::getDisplayType() const ...@@ -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<LLMuteList>::getInstance(); // Call the "base" implementation.
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// LLMuteList() // LLMuteList()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -169,6 +154,18 @@ LLMuteList::LLMuteList() : ...@@ -169,6 +154,18 @@ LLMuteList::LLMuteList() :
mIsLoaded(FALSE) mIsLoaded(FALSE)
{ {
gGenericDispatcher.addHandler("emptymutelist", &sDispatchEmptyMuteList); 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<void**>(NULL)));
gMessageSystem.callWhenReady(boost::bind(&LLMessageSystem::setHandlerFuncFast, _1,
_PREHASH_UseCachedMuteList, processUseCachedMuteList,
static_cast<void**>(NULL)));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -84,11 +84,6 @@ class LLMuteList : public LLSingleton<LLMuteList> ...@@ -84,11 +84,6 @@ class LLMuteList : public LLSingleton<LLMuteList>
LLMuteList(); LLMuteList();
~LLMuteList(); ~LLMuteList();
// Implemented locally so that we can perform some delayed initialization.
// Callers should be careful to call this one and not LLSingleton<LLMuteList>::getInstance()
// which would circumvent that mechanism. -MG
static LLMuteList* getInstance();
void addObserver(LLMuteListObserver* observer); void addObserver(LLMuteListObserver* observer);
void removeObserver(LLMuteListObserver* observer); void removeObserver(LLMuteListObserver* observer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment