summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandreykproductengine <akleshchev@productengine.com>2017-04-25 17:48:34 +0300
committerandreykproductengine <akleshchev@productengine.com>2017-04-25 17:48:34 +0300
commit0dcb423cf3dc42e11621eece972801b036657e91 (patch)
tree88b0493918f6340d2e038b9cc0cde1cad6f493ff
parent288f93c7e0aa605464ddb09a3cdca504c0805c48 (diff)
MAINT-7145 Eliminate LLSingleton circular references
-rw-r--r--indra/llcommon/llsingleton.cpp32
-rw-r--r--indra/llui/llnotifications.cpp18
-rw-r--r--indra/newview/lldaycyclemanager.cpp22
-rw-r--r--indra/newview/llenvmanager.cpp21
-rw-r--r--indra/newview/llsky.cpp2
-rw-r--r--indra/newview/llstartup.cpp1
-rw-r--r--indra/newview/llwlparammanager.cpp25
-rw-r--r--indra/newview/llwlparammanager.h5
8 files changed, 65 insertions, 61 deletions
diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp
index 9025e53bb2..a3a87edd88 100644
--- a/indra/llcommon/llsingleton.cpp
+++ b/indra/llcommon/llsingleton.cpp
@@ -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
{
diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp
index 0cb959a315..604092d536 100644
--- a/indra/llui/llnotifications.cpp
+++ b/indra/llui/llnotifications.cpp
@@ -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);
}
diff --git a/indra/newview/lldaycyclemanager.cpp b/indra/newview/lldaycyclemanager.cpp
index e7bf989850..803e2b2fb2 100644
--- a/indra/newview/lldaycyclemanager.cpp
+++ b/indra/newview/lldaycyclemanager.cpp
@@ -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()
diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp
index b97e483fd9..12c3070474 100644
--- a/indra/newview/llenvmanager.cpp
+++ b/indra/newview/llenvmanager.cpp
@@ -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()
diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp
index 7a292fe0ef..3ef89ba920 100644
--- a/indra/newview/llsky.cpp
+++ b/indra/newview/llsky.cpp
@@ -341,8 +341,6 @@ void LLSky::init(const LLVector3 &sun_direction)
LLGLState::checkTextureChannels();
mUpdatedThisFrame = TRUE;
-
- LLEnvManagerNew::instance().usePrefs(); //inits day cycles and water
}
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 0a85344025..33b6352bf5 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -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();
diff --git a/indra/newview/llwlparammanager.cpp b/indra/newview/llwlparammanager.cpp
index debe467a9a..4b4393b07b 100644
--- a/indra/newview/llwlparammanager.cpp
+++ b/indra/newview/llwlparammanager.cpp
@@ -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);
}
diff --git a/indra/newview/llwlparammanager.h b/indra/newview/llwlparammanager.h
index db3c285e76..a8029839a7 100644
--- a/indra/newview/llwlparammanager.h
+++ b/indra/newview/llwlparammanager.h
@@ -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.)