MAINT-7145 Eliminate LLSingleton circular references
parent
288f93c7e0
commit
0dcb423cf3
|
|
@ -220,6 +220,9 @@ void LLSingletonBase::capture_dependency(list_t& initializing, EInitState initSt
|
|||
std::find(initializing.begin(), initializing.end(), this);
|
||||
if (found != initializing.end())
|
||||
{
|
||||
list_t::const_iterator it_next = found;
|
||||
it_next++;
|
||||
|
||||
// Report the circularity. Requiring the coder to dig through the
|
||||
// logic to diagnose exactly how we got here is less than helpful.
|
||||
std::ostringstream out;
|
||||
|
|
@ -238,11 +241,30 @@ void LLSingletonBase::capture_dependency(list_t& initializing, EInitState initSt
|
|||
// otherwise we'd be returning a pointer to a partially-
|
||||
// constructed object! But from initSingleton() is okay: that
|
||||
// method exists specifically to support circularity.
|
||||
// Decide which log helper to call based on initState. They have
|
||||
// identical signatures.
|
||||
((initState == CONSTRUCTING)? logerrs : logwarns)
|
||||
("LLSingleton circularity: ", out.str().c_str(),
|
||||
demangle(typeid(*this).name()).c_str(), "");
|
||||
// Decide which log helper to call.
|
||||
if (initState == CONSTRUCTING)
|
||||
{
|
||||
logerrs("LLSingleton circularity in Constructor: ", out.str().c_str(),
|
||||
demangle(typeid(*this).name()).c_str(), "");
|
||||
}
|
||||
else if (it_next == initializing.end())
|
||||
{
|
||||
// Points to self after construction, but during initialization.
|
||||
// Singletons can initialize other classes that depend onto them,
|
||||
// so this is expected.
|
||||
//
|
||||
// Example: LLNotifications singleton initializes default channels.
|
||||
// Channels register themselves with singleton once done.
|
||||
logdebugs("LLSingleton circularity: ", out.str().c_str(),
|
||||
demangle(typeid(*this).name()).c_str(), "");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Actual circularity with other singleton (or single singleton is used extensively).
|
||||
// Dependency can be unclear.
|
||||
logwarns("LLSingleton circularity: ", out.str().c_str(),
|
||||
demangle(typeid(*this).name()).c_str(), "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1405,20 +1405,14 @@ void LLNotifications::createDefaultChannels()
|
|||
mDefaultChannels.push_back(new LLPersistentNotificationChannel());
|
||||
|
||||
// connect action methods to these channels
|
||||
LLNotifications::instance().getChannel("Enabled")->
|
||||
connectFailedFilter(&defaultResponse);
|
||||
LLNotifications::instance().getChannel("Expiration")->
|
||||
connectChanged(boost::bind(&LLNotifications::expirationHandler, this, _1));
|
||||
getChannel("Enabled")->connectFailedFilter(&defaultResponse);
|
||||
getChannel("Expiration")->connectChanged(boost::bind(&LLNotifications::expirationHandler, this, _1));
|
||||
// uniqueHandler slot should be added as first slot of the signal due to
|
||||
// usage LLStopWhenHandled combiner in LLStandardSignal
|
||||
LLNotifications::instance().getChannel("Unique")->
|
||||
connectAtFrontChanged(boost::bind(&LLNotifications::uniqueHandler, this, _1));
|
||||
LLNotifications::instance().getChannel("Unique")->
|
||||
connectFailedFilter(boost::bind(&LLNotifications::failedUniquenessTest, this, _1));
|
||||
LLNotifications::instance().getChannel("Ignore")->
|
||||
connectFailedFilter(&handleIgnoredNotification);
|
||||
LLNotifications::instance().getChannel("VisibilityRules")->
|
||||
connectFailedFilter(&visibilityRuleMached);
|
||||
getChannel("Unique")->connectAtFrontChanged(boost::bind(&LLNotifications::uniqueHandler, this, _1));
|
||||
getChannel("Unique")->connectFailedFilter(boost::bind(&LLNotifications::failedUniquenessTest, this, _1));
|
||||
getChannel("Ignore")->connectFailedFilter(&handleIgnoredNotification);
|
||||
getChannel("VisibilityRules")->connectFailedFilter(&visibilityRuleMached);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -163,28 +163,6 @@ void LLDayCycleManager::initSingleton()
|
|||
{
|
||||
LL_DEBUGS("Windlight") << "Loading all day cycles" << LL_ENDL;
|
||||
loadAllPresets();
|
||||
|
||||
// presets loaded, can set params
|
||||
if (LLEnvManagerNew::instance().getUseDayCycle())
|
||||
{
|
||||
LLSD params;
|
||||
std::string preferred_day = LLEnvManagerNew::getInstance()->getDayCycleName();
|
||||
if (getPreset(preferred_day, params))
|
||||
{
|
||||
// Same as through useDayCycle(), but it will call LLDayCycleManager and we are initializing
|
||||
// so no need to cycle
|
||||
LLWLParamManager::getInstance()->applyDayCycleParams(params, LLEnvKey::SCOPE_LOCAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
LL_WARNS() << "No day cycle named " << preferred_day << ", reverting LLWLParamManager to defaults" << LL_ENDL;
|
||||
LLWLParamManager::getInstance()->setDefaultDay();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LLWLParamManager::getInstance()->setDefaultDay();
|
||||
}
|
||||
}
|
||||
|
||||
void LLDayCycleManager::loadAllPresets()
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content)
|
|||
mCachedRegionPrefs = new_settings;
|
||||
|
||||
// Load region sky presets.
|
||||
LLWLParamManager::instance().refreshRegionPresets();
|
||||
LLWLParamManager::instance().refreshRegionPresets(getRegionSettings().getSkyMap());
|
||||
|
||||
// If using server settings, update managers.
|
||||
if (getUseRegionSettings())
|
||||
|
|
@ -509,6 +509,25 @@ void LLEnvManagerNew::initSingleton()
|
|||
LL_DEBUGS("Windlight") << "Initializing LLEnvManagerNew" << LL_ENDL;
|
||||
|
||||
loadUserPrefs();
|
||||
|
||||
// preferences loaded, can set params
|
||||
std::string preferred_day = getDayCycleName();
|
||||
if (!useDayCycle(preferred_day, LLEnvKey::SCOPE_LOCAL))
|
||||
{
|
||||
LL_WARNS() << "No day cycle named " << preferred_day << ", reverting LLWLParamManager to defaults" << LL_ENDL;
|
||||
LLWLParamManager::instance().setDefaultDay();
|
||||
}
|
||||
|
||||
std::string sky = getSkyPresetName();
|
||||
if (!useSkyPreset(sky))
|
||||
{
|
||||
LL_WARNS() << "No sky preset named " << sky << ", falling back to defaults" << LL_ENDL;
|
||||
LLWLParamManager::instance().setDefaultSky();
|
||||
|
||||
// *TODO: Fix user preferences accordingly.
|
||||
}
|
||||
|
||||
LLWLParamManager::instance().resetAnimator(0.5 /*noon*/, getUseDayCycle());
|
||||
}
|
||||
|
||||
void LLEnvManagerNew::updateSkyFromPrefs()
|
||||
|
|
|
|||
|
|
@ -341,8 +341,6 @@ void LLSky::init(const LLVector3 &sun_direction)
|
|||
LLGLState::checkTextureChannels();
|
||||
|
||||
mUpdatedThisFrame = TRUE;
|
||||
|
||||
LLEnvManagerNew::instance().usePrefs(); //inits day cycles and water
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1462,6 +1462,7 @@ bool idle_startup()
|
|||
LLGLState::checkStates();
|
||||
LLGLState::checkTextureChannels();
|
||||
|
||||
LLEnvManagerNew::getInstance()->usePrefs(); // Load all presets and settings
|
||||
gSky.init(initial_sun_direction);
|
||||
|
||||
LLGLState::checkStates();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@
|
|||
#include "llagent.h"
|
||||
#include "llviewerregion.h"
|
||||
|
||||
#include "llenvmanager.h"
|
||||
#include "llwlparamset.h"
|
||||
#include "llpostprocess.h"
|
||||
|
||||
|
|
@ -251,13 +250,13 @@ void LLWLParamManager::addAllSkies(const LLWLParamKey::EScope scope, const LLSD&
|
|||
}
|
||||
}
|
||||
|
||||
void LLWLParamManager::refreshRegionPresets()
|
||||
void LLWLParamManager::refreshRegionPresets(const LLSD& region_sky_presets)
|
||||
{
|
||||
// Remove all region sky presets because they may belong to a previously visited region.
|
||||
clearParamSetsOfScope(LLEnvKey::SCOPE_REGION);
|
||||
|
||||
// Add all sky presets belonging to the current region.
|
||||
addAllSkies(LLEnvKey::SCOPE_REGION, LLEnvManagerNew::instance().getRegionSettings().getSkyMap());
|
||||
addAllSkies(LLEnvKey::SCOPE_REGION, region_sky_presets);
|
||||
}
|
||||
|
||||
void LLWLParamManager::loadAllPresets()
|
||||
|
|
@ -489,7 +488,6 @@ bool LLWLParamManager::applyDayCycleParams(const LLSD& params, LLEnvKey::EScope
|
|||
void LLWLParamManager::setDefaultDay()
|
||||
{
|
||||
mDay.loadDayCycleFromFile("Default.xml");
|
||||
resetAnimator(0.5, LLEnvManagerNew::getInstance()->getUseDayCycle());
|
||||
}
|
||||
|
||||
bool LLWLParamManager::applySkyParams(const LLSD& params)
|
||||
|
|
@ -499,6 +497,12 @@ bool LLWLParamManager::applySkyParams(const LLSD& params)
|
|||
return true;
|
||||
}
|
||||
|
||||
void LLWLParamManager::setDefaultSky()
|
||||
{
|
||||
getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams);
|
||||
}
|
||||
|
||||
|
||||
void LLWLParamManager::resetAnimator(F32 curTime, bool run)
|
||||
{
|
||||
mAnimator.setTrack(mDay.mTimeMap, mDay.mDayRate,
|
||||
|
|
@ -677,19 +681,6 @@ void LLWLParamManager::initSingleton()
|
|||
|
||||
loadAllPresets();
|
||||
|
||||
// *HACK - sets cloud scrolling to what we want... fix this better in the future
|
||||
std::string sky = LLEnvManagerNew::instance().getSkyPresetName();
|
||||
if (!getParamSet(LLWLParamKey(sky, LLWLParamKey::SCOPE_LOCAL), mCurParams))
|
||||
{
|
||||
LL_WARNS() << "No sky preset named " << sky << ", falling back to defaults" << LL_ENDL;
|
||||
getParamSet(LLWLParamKey("Default", LLWLParamKey::SCOPE_LOCAL), mCurParams);
|
||||
|
||||
// *TODO: Fix user preferences accordingly.
|
||||
}
|
||||
|
||||
// set it to noon
|
||||
resetAnimator(0.5, LLEnvManagerNew::instance().getUseDayCycle());
|
||||
|
||||
// but use linden time sets it to what the estate is
|
||||
mAnimator.setTimeType(LLWLAnimator::TIME_LINDEN);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "llenvmanager.h"
|
||||
#include "llwlparamset.h"
|
||||
#include "llwlanimator.h"
|
||||
#include "llwldaycycle.h"
|
||||
|
|
@ -246,6 +245,8 @@ public:
|
|||
/// apply specified fixed sky params
|
||||
bool applySkyParams(const LLSD& params);
|
||||
|
||||
void setDefaultSky();
|
||||
|
||||
// get where the light is pointing
|
||||
inline LLVector4 getLightDir(void) const;
|
||||
|
||||
|
|
@ -305,7 +306,7 @@ public:
|
|||
void addAllSkies(LLEnvKey::EScope scope, const LLSD& preset_map);
|
||||
|
||||
/// refresh region-scope presets
|
||||
void refreshRegionPresets();
|
||||
void refreshRegionPresets(const LLSD& region_sky_presets);
|
||||
|
||||
// returns all skies referenced by the current day cycle (in mDay), with their final names
|
||||
// side effect: applies changes to all internal structures! (trashes all unreferenced skies in scope, keys in day cycle rescoped to scope, etc.)
|
||||
|
|
|
|||
Loading…
Reference in New Issue