summaryrefslogtreecommitdiff
path: root/indra/llxml
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llxml')
-rwxr-xr-x[-rw-r--r--]indra/llxml/CMakeLists.txt30
-rwxr-xr-x[-rw-r--r--]indra/llxml/llcontrol.cpp229
-rwxr-xr-x[-rw-r--r--]indra/llxml/llcontrol.h81
-rwxr-xr-x[-rw-r--r--]indra/llxml/llcontrolgroupreader.h0
-rwxr-xr-x[-rw-r--r--]indra/llxml/llxmlnode.cpp254
-rwxr-xr-x[-rw-r--r--]indra/llxml/llxmlnode.h15
-rwxr-xr-x[-rw-r--r--]indra/llxml/llxmlparser.cpp2
-rwxr-xr-x[-rw-r--r--]indra/llxml/llxmlparser.h2
-rwxr-xr-x[-rw-r--r--]indra/llxml/llxmltree.cpp40
-rwxr-xr-x[-rw-r--r--]indra/llxml/llxmltree.h4
-rwxr-xr-x[-rw-r--r--]indra/llxml/tests/llcontrol_test.cpp8
11 files changed, 346 insertions, 319 deletions
diff --git a/indra/llxml/CMakeLists.txt b/indra/llxml/CMakeLists.txt
index eb5166ee71..17400a203e 100644..100755
--- a/indra/llxml/CMakeLists.txt
+++ b/indra/llxml/CMakeLists.txt
@@ -13,6 +13,9 @@ include_directories(
${LLMATH_INCLUDE_DIRS}
${LLVFS_INCLUDE_DIRS}
)
+include_directories(
+ ${LLCOMMON_SYSTEM_INCLUDE_DIRS}
+ )
set(llxml_SOURCE_FILES
llcontrol.cpp
@@ -40,32 +43,31 @@ add_library (llxml ${llxml_SOURCE_FILES})
# Libraries on which this library depends, needed for Linux builds
# Sort by high-level to low-level
target_link_libraries( llxml
- llvfs
- llmath
+ ${LLVFS_LIBRARIES}
+ ${LLMATH_LIBRARIES}
+ ${LLCOMMON_LIBRARIES}
${EXPAT_LIBRARIES}
)
+# tests
-if(LL_TESTS)
- # tests
+if (LL_TESTS)
+ # unit tests
- # unit tests
-
- SET(llxml_TEST_SOURCE_FILES
+ SET(llxml_TEST_SOURCE_FILES
# none yet!
)
- LL_ADD_PROJECT_UNIT_TESTS(llxml "${llxml_TEST_SOURCE_FILES}")
+ LL_ADD_PROJECT_UNIT_TESTS(llxml "${llxml_TEST_SOURCE_FILES}")
- # integration tests
+ # integration tests
- # set(TEST_DEBUG on)
- set(test_libs
+ # set(TEST_DEBUG on)
+ set(test_libs
${LLXML_LIBRARIES}
${WINDOWS_LIBRARIES}
${LLMATH_LIBRARIES}
${LLCOMMON_LIBRARIES}
)
- LL_ADD_INTEGRATION_TEST(llcontrol "" "${test_libs}")
-
-endif(LL_TESTS)
+ LL_ADD_INTEGRATION_TEST(llcontrol "" "${test_libs}")
+endif (LL_TESTS)
diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp
index 6c72609122..4e3d0ab392 100644..100755
--- a/indra/llxml/llcontrol.cpp
+++ b/indra/llxml/llcontrol.cpp
@@ -132,16 +132,16 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b)
LLControlVariable::LLControlVariable(const std::string& name, eControlType type,
LLSD initial, const std::string& comment,
- bool persist, bool hidefromsettingseditor)
+ ePersist persist, bool hidefromsettingseditor)
: mName(name),
mComment(comment),
mType(type),
mPersist(persist),
mHideFromSettingsEditor(hidefromsettingseditor)
{
- if (mPersist && mComment.empty())
+ if ((persist != PERSIST_NO) && mComment.empty())
{
- llerrs << "Must supply a comment for control " << mName << llendl;
+ LL_ERRS() << "Must supply a comment for control " << mName << LL_ENDL;
}
//Push back versus setValue'ing here, since we don't want to call a signal yet
mValues.push_back(initial);
@@ -201,7 +201,8 @@ void LLControlVariable::setValue(const LLSD& new_value, bool saved_value)
}
LLSD storable_value = getComparableValue(new_value);
- bool value_changed = llsd_compare(getValue(), storable_value) == FALSE;
+ LLSD original_value = getValue();
+ bool value_changed = llsd_compare(original_value, storable_value) == FALSE;
if(saved_value)
{
// If we're going to save this value, return to default but don't fire
@@ -237,7 +238,7 @@ void LLControlVariable::setValue(const LLSD& new_value, bool saved_value)
if(value_changed)
{
- mCommitSignal(this, storable_value);
+ firePropertyChanged(original_value);
}
}
@@ -249,16 +250,17 @@ void LLControlVariable::setDefaultValue(const LLSD& value)
// *NOTE: Default values are not saved, only read.
LLSD comparable_value = getComparableValue(value);
- bool value_changed = (llsd_compare(getValue(), comparable_value) == FALSE);
+ LLSD original_value = getValue();
+ bool value_changed = (llsd_compare(original_value, comparable_value) == FALSE);
resetToDefault(false);
mValues[0] = comparable_value;
if(value_changed)
{
- firePropertyChanged();
+ firePropertyChanged(original_value);
}
}
-void LLControlVariable::setPersist(bool state)
+void LLControlVariable::setPersist(ePersist state)
{
mPersist = state;
}
@@ -277,6 +279,8 @@ void LLControlVariable::resetToDefault(bool fire_signal)
{
//The first setting is always the default
//Pop to it and fire off the listener
+ LLSD originalValue = mValues.back();
+
while(mValues.size() > 1)
{
mValues.pop_back();
@@ -284,14 +288,33 @@ void LLControlVariable::resetToDefault(bool fire_signal)
if(fire_signal)
{
- firePropertyChanged();
+ firePropertyChanged(originalValue);
}
}
-bool LLControlVariable::isSaveValueDefault()
-{
- return (mValues.size() == 1)
- || ((mValues.size() > 1) && llsd_compare(mValues[1], mValues[0]));
+bool LLControlVariable::shouldSave(bool nondefault_only)
+{
+ // This method is used to decide whether we should save a given
+ // variable. Two of the three values of mPersist are easy.
+ if (mPersist == PERSIST_NO)
+ return false;
+
+ if (mPersist == PERSIST_ALWAYS)
+ return true;
+
+ // PERSIST_NONDFT
+ // If caller doesn't need us to filter, just save.
+ if (! nondefault_only)
+ return true;
+
+ // PERSIST_NONDFT: caller only wants us to save this variable if its value
+ // differs from default.
+ if (isDefault()) // never been altered
+ return false;
+
+ // We've set at least one other value: compare it to default. Save only if
+ // they differ.
+ return ! llsd_compare(getSaveValue(), getDefault());
}
LLSD LLControlVariable::getSaveValue() const
@@ -351,12 +374,12 @@ std::string LLControlGroup::typeEnumToString(eControlType typeenum)
return mTypeString[typeenum];
}
-BOOL LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist, BOOL hidefromsettingseditor)
+LLControlVariable* LLControlGroup::declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, LLControlVariable::ePersist persist, BOOL hidefromsettingseditor)
{
LLControlVariable* existing_control = getControl(name);
if (existing_control)
{
- if (persist && existing_control->isType(type))
+ if ((persist != LLControlVariable::PERSIST_NO) && existing_control->isType(type))
{
if (!existing_control->llsd_compare(existing_control->getDefault(), initial_val))
{
@@ -368,68 +391,68 @@ BOOL LLControlGroup::declareControl(const std::string& name, eControlType type,
}
else
{
- llwarns << "Control named " << name << " already exists, ignoring new declaration." << llendl;
+ LL_WARNS("Settings") << "Control named " << name << " already exists, ignoring new declaration." << LL_ENDL;
}
- return TRUE;
+ return existing_control;
}
// if not, create the control and add it to the name table
LLControlVariable* control = new LLControlVariable(name, type, initial_val, comment, persist, hidefromsettingseditor);
mNameTable[name] = control;
- return TRUE;
+ return control;
}
-BOOL LLControlGroup::declareU32(const std::string& name, const U32 initial_val, const std::string& comment, BOOL persist)
+LLControlVariable* LLControlGroup::declareU32(const std::string& name, const U32 initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_U32, (LLSD::Integer) initial_val, comment, persist);
}
-BOOL LLControlGroup::declareS32(const std::string& name, const S32 initial_val, const std::string& comment, BOOL persist)
+LLControlVariable* LLControlGroup::declareS32(const std::string& name, const S32 initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_S32, initial_val, comment, persist);
}
-BOOL LLControlGroup::declareF32(const std::string& name, const F32 initial_val, const std::string& comment, BOOL persist)
+LLControlVariable* LLControlGroup::declareF32(const std::string& name, const F32 initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_F32, initial_val, comment, persist);
}
-BOOL LLControlGroup::declareBOOL(const std::string& name, const BOOL initial_val, const std::string& comment, BOOL persist)
+LLControlVariable* LLControlGroup::declareBOOL(const std::string& name, const BOOL initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_BOOLEAN, initial_val, comment, persist);
}
-BOOL LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, BOOL persist)
+LLControlVariable* LLControlGroup::declareString(const std::string& name, const std::string& initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_STRING, initial_val, comment, persist);
}
-BOOL LLControlGroup::declareVec3(const std::string& name, const LLVector3 &initial_val, const std::string& comment, BOOL persist)
+LLControlVariable* LLControlGroup::declareVec3(const std::string& name, const LLVector3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_VEC3, initial_val.getValue(), comment, persist);
}
-BOOL LLControlGroup::declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, BOOL persist)
+LLControlVariable* LLControlGroup::declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_VEC3D, initial_val.getValue(), comment, persist);
}
-BOOL LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, BOOL persist)
+LLControlVariable* LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist)
{
return declareControl(name, TYPE_RECT, initial_val.getValue(), comment, persist);
}
-BOOL LLControlGroup::declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist )
+LLControlVariable* LLControlGroup::declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, LLControlVariable::ePersist persist )
{
return declareControl(name, TYPE_COL4, initial_val.getValue(), comment, persist);
}
-BOOL LLControlGroup::declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, BOOL persist )
+LLControlVariable* LLControlGroup::declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist )
{
return declareControl(name, TYPE_COL3, initial_val.getValue(), comment, persist);
}
-BOOL LLControlGroup::declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, BOOL persist )
+LLControlVariable* LLControlGroup::declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, LLControlVariable::ePersist persist )
{
return declareControl(name, TYPE_LLSD, initial_val, comment, persist);
}
@@ -589,7 +612,7 @@ void LLControlGroup::setUntypedValue(const std::string& name, const LLSD& val)
}
else
{
- CONTROL_ERRS << "Invalid control " << name << llendl;
+ CONTROL_ERRS << "Invalid control " << name << LL_ENDL;
}
}
@@ -607,14 +630,14 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
if (!xml_controls.parseFile(filename))
{
- llwarns << "Unable to open control file " << filename << llendl;
+ LL_WARNS("Settings") << "Unable to open control file " << filename << LL_ENDL;
return 0;
}
LLXmlTreeNode* rootp = xml_controls.getRoot();
if (!rootp || !rootp->hasAttribute("version"))
{
- llwarns << "No valid settings header found in control file " << filename << llendl;
+ LL_WARNS("Settings") << "No valid settings header found in control file " << filename << LL_ENDL;
return 0;
}
@@ -627,7 +650,7 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
// Check file version
if (version != CURRENT_VERSION)
{
- llinfos << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << llendl;
+ LL_INFOS("Settings") << filename << " does not appear to be a version " << CURRENT_VERSION << " controls file" << LL_ENDL;
return 0;
}
@@ -645,7 +668,7 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
if (!name.empty())
{
//read in to end of line
- llwarns << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << llendl;
+ LL_WARNS("Settings") << "LLControlGroup::loadFromFile() : Trying to set \"" << name << "\", setting doesn't exist." << LL_ENDL;
}
child_nodep = rootp->getNextChild();
continue;
@@ -660,11 +683,11 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
switch(declare_as)
{
case TYPE_COL4:
- declareColor4(name, LLColor4::white, LLStringUtil::null, NO_PERSIST);
+ declareColor4(name, LLColor4::white, LLStringUtil::null, LLControlVariable::PERSIST_NO);
break;
case TYPE_STRING:
default:
- declareString(name, LLStringUtil::null, LLStringUtil::null, NO_PERSIST);
+ declareString(name, LLStringUtil::null, LLStringUtil::null, LLControlVariable::PERSIST_NO);
break;
}
}
@@ -799,61 +822,48 @@ U32 LLControlGroup::saveToFile(const std::string& filename, BOOL nondefault_only
LLControlVariable* control = iter->second;
if (!control)
{
- llwarns << "Tried to save invalid control: " << iter->first << llendl;
+ LL_WARNS("Settings") << "Tried to save invalid control: " << iter->first << LL_ENDL;
}
-
- if( control && control->isPersisted() )
+ else if( control->shouldSave(nondefault_only) )
{
- if (!(nondefault_only && (control->isSaveValueDefault())))
- {
- settings[iter->first]["Type"] = typeEnumToString(control->type());
- settings[iter->first]["Comment"] = control->getComment();
- settings[iter->first]["Value"] = control->getSaveValue();
- ++num_saved;
- }
- else
- {
- // Debug spam
- // llinfos << "Skipping " << control->getName() << llendl;
- }
+ settings[iter->first]["Type"] = typeEnumToString(control->type());
+ settings[iter->first]["Comment"] = control->getComment();
+ settings[iter->first]["Value"] = control->getSaveValue();
+ ++num_saved;
}
}
llofstream file;
- file.open(filename);
+ file.open(filename.c_str());
if (file.is_open())
{
LLSDSerialize::toPrettyXML(settings, file);
file.close();
- llinfos << "Saved to " << filename << llendl;
+ LL_INFOS("Settings") << "Saved to " << filename << LL_ENDL;
}
else
{
// This is a warning because sometime we want to use settings files which can't be written...
- llwarns << "Unable to open settings file: " << filename << llendl;
+ LL_WARNS("Settings") << "Unable to open settings file: " << filename << LL_ENDL;
return 0;
}
return num_saved;
}
-U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values)
+U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_values, bool save_values)
{
- std::string name;
LLSD settings;
- LLSD control_map;
llifstream infile;
- infile.open(filename);
+ infile.open(filename.c_str());
if(!infile.is_open())
{
- llwarns << "Cannot find file " << filename << " to load." << llendl;
+ LL_WARNS("Settings") << "Cannot find file " << filename << " to load." << LL_ENDL;
return 0;
}
- S32 ret = LLSDSerialize::fromXML(settings, infile);
-
- if (ret <= 0)
+ if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(settings, infile))
{
infile.close();
- llwarns << "Unable to open LLSD control file " << filename << ". Trying Legacy Method." << llendl;
+ LL_WARNS("Settings") << "Unable to parse LLSD control file " << filename << ". Trying Legacy Method." << LL_ENDL;
return loadFromFileLegacy(filename, TRUE, TYPE_STRING);
}
@@ -862,13 +872,14 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
for(LLSD::map_const_iterator itr = settings.beginMap(); itr != settings.endMap(); ++itr)
{
- bool persist = true;
- name = (*itr).first;
- control_map = (*itr).second;
+ LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT;
+ std::string const & name = itr->first;
+ LLSD const & control_map = itr->second;
if(control_map.has("Persist"))
{
- persist = control_map["Persist"].asInteger();
+ persist = control_map["Persist"].asInteger()?
+ LLControlVariable::PERSIST_NONDFT : LLControlVariable::PERSIST_NO;
}
// Sometimes we want to use the settings system to provide cheap persistence, but we
@@ -887,6 +898,8 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
LLControlVariable* existing_control = getControl(name);
if(existing_control)
{
+ // set_default_values is true when we're loading the initial,
+ // immutable files from app_settings, e.g. settings.xml.
if(set_default_values)
{
// Override all previously set properties of this control.
@@ -901,21 +914,56 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
}
else
{
- llerrs << "Mismatched type of control variable '"
+ LL_ERRS() << "Mismatched type of control variable '"
<< name << "' found while loading '"
- << filename << "'." << llendl;
+ << filename << "'." << LL_ENDL;
}
}
else if(existing_control->isPersisted())
{
-
- existing_control->setValue(control_map["Value"]);
+ // save_values is specifically false for (e.g.)
+ // SessionSettingsFile and UserSessionSettingsFile -- in other
+ // words, for a file that's supposed to be transient.
+ existing_control->setValue(control_map["Value"], save_values);
}
// *NOTE: If not persisted and not setting defaults,
// the value should not get loaded.
}
else
{
+ // We've never seen this control before. Either we're loading up
+ // the initial set of default settings files (set_default_values)
+ // -- or we're loading user settings last saved by a viewer that
+ // supports a superset of the variables we know.
+ // CHOP-962: if we're loading an unrecognized user setting, make
+ // sure we save it later. If you try an experimental viewer, tweak
+ // a new setting, briefly revert to an old viewer, then return to
+ // the new one, we don't want the old viewer to discard the
+ // setting you changed.
+ if (! set_default_values)
+ {
+ // Using PERSIST_ALWAYS insists that saveToFile() (which calls
+ // LLControlVariable::shouldSave()) must save this control
+ // variable regardless of its value. We can safely set this
+ // LLControlVariable persistent because the 'persistent' flag
+ // is not itself persisted!
+ persist = LLControlVariable::PERSIST_ALWAYS;
+ // We want to mention unrecognized user settings variables
+ // (e.g. from a newer version of the viewer) in the log. But
+ // we also arrive here for Boolean variables generated by
+ // the notifications subsystem when the user checks "Don't
+ // show me this again." These aren't declared in settings.xml;
+ // they're actually named for the notification they suppress.
+ // We don't want to mention those. Apologies, this is a bit of
+ // a hack: we happen to know that user settings go into an
+ // LLControlGroup whose name is "Global".
+ if (getKey() == "Global")
+ {
+ LL_INFOS("LLControlGroup") << "preserving unrecognized " << getKey()
+ << " settings variable " << name << LL_ENDL;
+ }
+ }
+
declareControl(name,
typeStringToEnum(control_map["Type"].asString()),
control_map["Value"],
@@ -924,10 +972,11 @@ U32 LLControlGroup::loadFromFile(const std::string& filename, bool set_default_v
hidefromsettingseditor
);
}
-
+
++validitems;
}
+ LL_DEBUGS("Settings") << "Loaded " << validitems << " settings from " << filename << LL_ENDL;
return validitems;
}
@@ -964,7 +1013,7 @@ void main()
BOOL_CONTROL baz;
U32 count = gGlobals.loadFromFile("controls.ini");
- llinfos << "Loaded " << count << " controls" << llendl;
+ LL_INFOS("Settings") << "Loaded " << count << " controls" << LL_ENDL;
// test insertion
foo = new LLControlVariable<F32>("gFoo", 5.f, 1.f, 20.f);
@@ -1121,7 +1170,7 @@ bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::strin
return sd.asBoolean();
else
{
- CONTROL_ERRS << "Invalid BOOL value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid BOOL value for " << control_name << ": " << sd << LL_ENDL;
return FALSE;
}
}
@@ -1133,7 +1182,7 @@ S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string&
return sd.asInteger();
else
{
- CONTROL_ERRS << "Invalid S32 value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid S32 value for " << control_name << ": " << sd << LL_ENDL;
return 0;
}
}
@@ -1145,7 +1194,7 @@ U32 convert_from_llsd<U32>(const LLSD& sd, eControlType type, const std::string&
return sd.asInteger();
else
{
- CONTROL_ERRS << "Invalid U32 value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid U32 value for " << control_name << ": " << sd << LL_ENDL;
return 0;
}
}
@@ -1157,7 +1206,7 @@ F32 convert_from_llsd<F32>(const LLSD& sd, eControlType type, const std::string&
return (F32) sd.asReal();
else
{
- CONTROL_ERRS << "Invalid F32 value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid F32 value for " << control_name << ": " << sd << LL_ENDL;
return 0.0f;
}
}
@@ -1169,7 +1218,7 @@ std::string convert_from_llsd<std::string>(const LLSD& sd, eControlType type, co
return sd.asString();
else
{
- CONTROL_ERRS << "Invalid string value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid string value for " << control_name << ": " << sd << LL_ENDL;
return LLStringUtil::null;
}
}
@@ -1187,7 +1236,7 @@ LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const
return (LLVector3)sd;
else
{
- CONTROL_ERRS << "Invalid LLVector3 value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid LLVector3 value for " << control_name << ": " << sd << LL_ENDL;
return LLVector3::zero;
}
}
@@ -1199,7 +1248,7 @@ LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, cons
return (LLVector3d)sd;
else
{
- CONTROL_ERRS << "Invalid LLVector3d value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid LLVector3d value for " << control_name << ": " << sd << LL_ENDL;
return LLVector3d::zero;
}
}
@@ -1211,7 +1260,7 @@ LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::s
return LLRect(sd);
else
{
- CONTROL_ERRS << "Invalid rect value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid rect value for " << control_name << ": " << sd << LL_ENDL;
return LLRect::null;
}
}
@@ -1225,26 +1274,26 @@ LLColor4 convert_from_llsd<LLColor4>(const LLSD& sd, eControlType type, const st
LLColor4 color(sd);
if (color.mV[VRED] < 0.f || color.mV[VRED] > 1.f)
{
- llwarns << "Color " << control_name << " red value out of range: " << color << llendl;
+ LL_WARNS("Settings") << "Color " << control_name << " red value out of range: " << color << LL_ENDL;
}
else if (color.mV[VGREEN] < 0.f || color.mV[VGREEN] > 1.f)
{
- llwarns << "Color " << control_name << " green value out of range: " << color << llendl;
+ LL_WARNS("Settings") << "Color " << control_name << " green value out of range: " << color << LL_ENDL;
}
else if (color.mV[VBLUE] < 0.f || color.mV[VBLUE] > 1.f)
{
- llwarns << "Color " << control_name << " blue value out of range: " << color << llendl;
+ LL_WARNS("Settings") << "Color " << control_name << " blue value out of range: " << color << LL_ENDL;
}
else if (color.mV[VALPHA] < 0.f || color.mV[VALPHA] > 1.f)
{
- llwarns << "Color " << control_name << " alpha value out of range: " << color << llendl;
+ LL_WARNS("Settings") << "Color " << control_name << " alpha value out of range: " << color << LL_ENDL;
}
return LLColor4(sd);
}
else
{
- CONTROL_ERRS << "Control " << control_name << " not a color" << llendl;
+ CONTROL_ERRS << "Control " << control_name << " not a color" << LL_ENDL;
return LLColor4::white;
}
}
@@ -1256,7 +1305,7 @@ LLColor3 convert_from_llsd<LLColor3>(const LLSD& sd, eControlType type, const st
return sd;
else
{
- CONTROL_ERRS << "Invalid LLColor3 value for " << control_name << ": " << sd << llendl;
+ CONTROL_ERRS << "Invalid LLColor3 value for " << control_name << ": " << sd << LL_ENDL;
return LLColor3::white;
}
}
@@ -1291,13 +1340,13 @@ static LLCachedControl<std::string> test_BrowserHomePage("BrowserHomePage", "hah
void test_cached_control()
{
-#define TEST_LLCC(T, V) if((T)mySetting_##T != V) llerrs << "Fail "#T << llendl
+#define TEST_LLCC(T, V) if((T)mySetting_##T != V) LL_ERRS() << "Fail "#T << LL_ENDL
TEST_LLCC(U32, 666);
TEST_LLCC(S32, (S32)-666);
TEST_LLCC(F32, (F32)-666.666);
TEST_LLCC(bool, true);
TEST_LLCC(BOOL, FALSE);
- if((std::string)mySetting_string != "Default String Value") llerrs << "Fail string" << llendl;
+ if((std::string)mySetting_string != "Default String Value") LL_ERRS() << "Fail string" << LL_ENDL;
TEST_LLCC(LLVector3, LLVector3(1.0f, 2.0f, 3.0f));
TEST_LLCC(LLVector3d, LLVector3d(6.0f, 5.0f, 4.0f));
TEST_LLCC(LLRect, LLRect(0, 0, 100, 500));
@@ -1306,7 +1355,7 @@ void test_cached_control()
TEST_LLCC(LLColor4U, LLColor4U(255, 200, 100, 255));
//There's no LLSD comparsion for LLCC yet. TEST_LLCC(LLSD, test_llsd);
- if((std::string)test_BrowserHomePage != "http://www.secondlife.com") llerrs << "Fail BrowserHomePage" << llendl;
+ if((std::string)test_BrowserHomePage != "http://www.secondlife.com") LL_ERRS() << "Fail BrowserHomePage" << LL_ENDL;
}
#endif // TEST_CACHED_CONTROL
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index 93975579cc..04575d81e0 100644..100755
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -29,8 +29,6 @@
#include "llboost.h"
#include "llevent.h"
-#include "llnametable.h"
-#include "llmap.h"
#include "llstring.h"
#include "llrect.h"
#include "llrefcount.h"
@@ -72,8 +70,6 @@ class LLVector3d;
class LLColor4;
class LLColor3;
-const BOOL NO_PERSIST = FALSE;
-
typedef enum e_control_type
{
TYPE_U32 = 0,
@@ -92,27 +88,36 @@ typedef enum e_control_type
class LLControlVariable : public LLRefCount
{
+ LOG_CLASS(LLControlVariable);
+
friend class LLControlGroup;
public:
typedef boost::signals2::signal<bool(LLControlVariable* control, const LLSD&), boost_boolean_combiner> validate_signal_t;
- typedef boost::signals2::signal<void(LLControlVariable* control, const LLSD&)> commit_signal_t;
+ typedef boost::signals2::signal<void(LLControlVariable* control, const LLSD&, const LLSD&)> commit_signal_t;
+
+ enum ePersist
+ {
+ PERSIST_NO, // don't save this var
+ PERSIST_NONDFT, // save this var if differs from default
+ PERSIST_ALWAYS // save this var even if has default value
+ };
private:
std::string mName;
std::string mComment;
eControlType mType;
- bool mPersist;
+ ePersist mPersist;
bool mHideFromSettingsEditor;
std::vector<LLSD> mValues;
-
+
commit_signal_t mCommitSignal;
validate_signal_t mValidateSignal;
public:
LLControlVariable(const std::string& name, eControlType type,
LLSD initial, const std::string& comment,
- bool persist = true, bool hidefromsettingseditor = false);
+ ePersist persist = PERSIST_NONDFT, bool hidefromsettingseditor = false);
virtual ~LLControlVariable();
@@ -129,8 +134,8 @@ public:
validate_signal_t* getValidateSignal() { return &mValidateSignal; }
bool isDefault() { return (mValues.size() == 1); }
- bool isSaveValueDefault();
- bool isPersisted() { return mPersist; }
+ bool shouldSave(bool nondefault_only);
+ bool isPersisted() { return mPersist != PERSIST_NO; }
bool isHiddenFromSettingsEditor() { return mHideFromSettingsEditor; }
LLSD get() const { return getValue(); }
LLSD getValue() const { return mValues.back(); }
@@ -140,15 +145,15 @@ public:
void set(const LLSD& val) { setValue(val); }
void setValue(const LLSD& value, bool saved_value = TRUE);
void setDefaultValue(const LLSD& value);
- void setPersist(bool state);
+ void setPersist(ePersist);
void setHiddenFromSettingsEditor(bool hide);
void setComment(const std::string& comment);
- void firePropertyChanged()
+private:
+ void firePropertyChanged(const LLSD &pPreviousValue)
{
- mCommitSignal(this, mValues.back());
+ mCommitSignal(this, mValues.back(), pPreviousValue);
}
-private:
LLSD getComparableValue(const LLSD& value);
bool llsd_compare(const LLSD& a, const LLSD & b);
};
@@ -159,7 +164,7 @@ typedef LLPointer<LLControlVariable> LLControlVariablePtr;
template <class T>
eControlType get_control_type()
{
- llwarns << "Usupported control type: " << typeid(T).name() << "." << llendl;
+ LL_WARNS() << "Usupported control type: " << typeid(T).name() << "." << LL_ENDL;
return TYPE_COUNT;
}
@@ -180,14 +185,17 @@ T convert_from_llsd(const LLSD& sd, eControlType type, const std::string& contro
//const U32 STRING_CACHE_SIZE = 10000;
class LLControlGroup : public LLInstanceTracker<LLControlGroup, std::string>
{
+ LOG_CLASS(LLControlGroup);
+
protected:
typedef std::map<std::string, LLControlVariablePtr > ctrl_name_table_t;
ctrl_name_table_t mNameTable;
std::string mTypeString[TYPE_COUNT];
+public:
eControlType typeStringToEnum(const std::string& typestr);
std::string typeEnumToString(eControlType typeenum);
-public:
+
LLControlGroup(const std::string& name);
~LLControlGroup();
void cleanup();
@@ -202,19 +210,19 @@ public:
virtual void apply(const std::string& name, LLControlVariable* control) = 0;
};
void applyToAll(ApplyFunctor* func);
-
- BOOL declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, BOOL persist, BOOL hidefromsettingseditor = FALSE);
- BOOL declareU32(const std::string& name, U32 initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareS32(const std::string& name, S32 initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareF32(const std::string& name, F32 initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareString(const std::string& name, const std::string &initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, BOOL persist = TRUE);
- BOOL declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, BOOL persist = TRUE);
- BOOL declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, BOOL persist = TRUE);
+
+ LLControlVariable* declareControl(const std::string& name, eControlType type, const LLSD initial_val, const std::string& comment, LLControlVariable::ePersist persist, BOOL hidefromsettingseditor = FALSE);
+ LLControlVariable* declareU32(const std::string& name, U32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareS32(const std::string& name, S32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareF32(const std::string& name, F32 initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareBOOL(const std::string& name, BOOL initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareString(const std::string& name, const std::string &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+ LLControlVariable* declareLLSD(const std::string& name, const LLSD &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
std::string getString(const std::string& name);
std::string getText(const std::string& name);
@@ -248,7 +256,8 @@ public:
}
else
{
- llwarns << "Control " << name << " not found." << llendl;
+ LL_WARNS() << "Control " << name << " not found." << LL_ENDL;
+ return T();
}
return convert_from_llsd<T>(value, type, name);
}
@@ -278,7 +287,7 @@ public:
}
else
{
- llwarns << "Invalid control " << name << llendl;
+ LL_WARNS() << "Invalid control " << name << LL_ENDL;
}
}
@@ -289,7 +298,7 @@ public:
// as the given type.
U32 loadFromFileLegacy(const std::string& filename, BOOL require_declaration = TRUE, eControlType declare_as = TYPE_STRING);
U32 saveToFile(const std::string& filename, BOOL nondefault_only);
- U32 loadFromFile(const std::string& filename, bool default_values = false);
+ U32 loadFromFile(const std::string& filename, bool default_values = false, bool save_values = true);
void resetToDefaults();
};
@@ -314,7 +323,7 @@ public:
{
if(!declareTypedControl(group, name, default_value, comment))
{
- llerrs << "The control could not be created!!!" << llendl;
+ LL_ERRS() << "The control could not be created!!!" << LL_ENDL;
}
}
@@ -327,7 +336,7 @@ public:
{
if(!group.controlExists(name))
{
- llerrs << "Control named " << name << "not found." << llendl;
+ LL_ERRS() << "Control named " << name << "not found." << LL_ENDL;
}
bindToControl(group, name);
@@ -362,7 +371,7 @@ private:
init_value = convert_to_llsd(default_value);
if(type < TYPE_COUNT)
{
- group.declareControl(name, type, init_value, comment, FALSE);
+ group.declareControl(name, type, init_value, comment, LLControlVariable::PERSIST_NO);
return true;
}
return false;
@@ -385,7 +394,7 @@ class LLCachedControl
{
public:
LLCachedControl(LLControlGroup& group,
- const std::string& name,
+ const std::string& name,
const T& default_value,
const std::string& comment = "Declared In Code")
{
diff --git a/indra/llxml/llcontrolgroupreader.h b/indra/llxml/llcontrolgroupreader.h
index 6a27a65499..6a27a65499 100644..100755
--- a/indra/llxml/llcontrolgroupreader.h
+++ b/indra/llxml/llcontrolgroupreader.h
diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp
index 8168f968cd..455df13e48 100644..100755
--- a/indra/llxml/llxmlnode.cpp
+++ b/indra/llxml/llxmlnode.cpp
@@ -43,8 +43,6 @@
#include "lluuid.h"
#include "lldir.h"
-const S32 MAX_COLUMN_WIDTH = 80;
-
// static
BOOL LLXMLNode::sStripEscapedStrings = TRUE;
BOOL LLXMLNode::sStripWhitespaceValues = FALSE;
@@ -147,13 +145,15 @@ LLXMLNodePtr LLXMLNode::deepCopy()
for (LLXMLChildList::iterator iter = mChildren->map.begin();
iter != mChildren->map.end(); ++iter)
{
- newnode->addChild(iter->second->deepCopy());
+ LLXMLNodePtr temp_ptr_for_gcc(iter->second->deepCopy());
+ newnode->addChild(temp_ptr_for_gcc);
}
}
for (LLXMLAttribList::iterator iter = mAttributes.begin();
iter != mAttributes.end(); ++iter)
{
- newnode->addChild(iter->second->deepCopy());
+ LLXMLNodePtr temp_ptr_for_gcc(iter->second->deepCopy());
+ newnode->addChild(temp_ptr_for_gcc);
}
return newnode;
@@ -259,7 +259,7 @@ BOOL LLXMLNode::removeChild(LLXMLNode *target_child)
return FALSE;
}
-void LLXMLNode::addChild(LLXMLNodePtr new_child, LLXMLNodePtr after_child)
+void LLXMLNode::addChild(LLXMLNodePtr& new_child)
{
if (new_child->mParent != NULL)
{
@@ -273,6 +273,11 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child, LLXMLNodePtr after_child)
new_child->mParent = this;
if (new_child->mIsAttribute)
{
+ LLXMLAttribList::iterator found_it = mAttributes.find(new_child->mName);
+ if (found_it != mAttributes.end())
+ {
+ removeChild(found_it->second);
+ }
mAttributes.insert(std::make_pair(new_child->mName, new_child));
}
else
@@ -285,49 +290,11 @@ void LLXMLNode::addChild(LLXMLNodePtr new_child, LLXMLNodePtr after_child)
}
mChildren->map.insert(std::make_pair(new_child->mName, new_child));
- // if after_child is specified, it damn well better be in the list of children
- // for this node. I'm not going to assert that, because it would be expensive,
- // but don't specify that parameter if you didn't get the value for it from the
- // list of children of this node!
- if (after_child.isNull())
- {
- if (mChildren->tail != new_child)
- {
- mChildren->tail->mNext = new_child;
- new_child->mPrev = mChildren->tail;
- mChildren->tail = new_child;
- }
- }
- // if after_child == parent, then put new_child at beginning
- else if (after_child == this)
- {
- // add to front of list
- new_child->mNext = mChildren->head;
- if (mChildren->head)
- {
- mChildren->head->mPrev = new_child;
- mChildren->head = new_child;
- }
- else // no children
- {
- mChildren->head = new_child;
- mChildren->tail = new_child;
- }
- }
- else
+ if (mChildren->tail != new_child)
{
- if (after_child->mNext.notNull())
- {
- // if after_child was not the last item, fix up some pointers
- after_child->mNext->mPrev = new_child;
- new_child->mNext = after_child->mNext;
- }
- new_child->mPrev = after_child;
- after_child->mNext = new_child;
- if (mChildren->tail == after_child)
- {
- mChildren->tail = new_child;
- }
+ mChildren->tail->mNext = new_child;
+ new_child->mPrev = mChildren->tail;
+ mChildren->tail = new_child;
}
}
@@ -343,8 +310,9 @@ LLXMLNodePtr LLXMLNode::createChild(const char* name, BOOL is_attribute)
// virtual
LLXMLNodePtr LLXMLNode::createChild(LLStringTableEntry* name, BOOL is_attribute)
{
- LLXMLNode* ret = new LLXMLNode(name, is_attribute);
+ LLXMLNodePtr ret(new LLXMLNode(name, is_attribute));
ret->mID.clear();
+
addChild(ret);
return ret;
}
@@ -358,11 +326,12 @@ BOOL LLXMLNode::deleteChild(LLXMLNode *child)
return FALSE;
}
-void LLXMLNode::setParent(LLXMLNodePtr new_parent)
+void LLXMLNode::setParent(LLXMLNodePtr& new_parent)
{
if (new_parent.notNull())
{
- new_parent->addChild(this);
+ LLXMLNodePtr this_ptr(this);
+ new_parent->addChild(this_ptr);
}
else
{
@@ -417,7 +386,7 @@ void XMLCALL StartXMLNode(void *userData,
if (NULL == parent)
{
- llwarns << "parent (userData) is NULL; aborting function" << llendl;
+ LL_WARNS() << "parent (userData) is NULL; aborting function" << LL_ENDL;
return;
}
@@ -605,7 +574,7 @@ bool LLXMLNode::updateNode(
if (!node || !update_node)
{
- llwarns << "Node invalid" << llendl;
+ LL_WARNS() << "Node invalid" << LL_ENDL;
return FALSE;
}
@@ -631,13 +600,14 @@ bool LLXMLNode::updateNode(
}
//update all of node's children with updateNodes children that match name
- LLXMLNodePtr child;
+ LLXMLNodePtr child = node->getFirstChild();
+ LLXMLNodePtr last_child = child;
LLXMLNodePtr updateChild;
for (updateChild = update_node->getFirstChild(); updateChild.notNull();
updateChild = updateChild->getNextSibling())
{
- for (child = node->getFirstChild(); child.notNull(); child = child->getNextSibling())
+ while(child.notNull())
{
std::string nodeName;
std::string updateName;
@@ -656,6 +626,22 @@ bool LLXMLNode::updateNode(
if ((nodeName != "") && (updateName == nodeName))
{
updateNode(child, updateChild);
+ last_child = child;
+ child = child->getNextSibling();
+ if (child.isNull())
+ {
+ child = node->getFirstChild();
+ }
+ break;
+ }
+
+ child = child->getNextSibling();
+ if (child.isNull())
+ {
+ child = node->getFirstChild();
+ }
+ if (child == last_child)
+ {
break;
}
}
@@ -664,27 +650,6 @@ bool LLXMLNode::updateNode(
return TRUE;
}
-
-// static
-LLXMLNodePtr LLXMLNode::replaceNode(LLXMLNodePtr node, LLXMLNodePtr update_node)
-{
- if (!node || !update_node)
- {
- llwarns << "Node invalid" << llendl;
- return node;
- }
-
- LLXMLNodePtr cloned_node = update_node->deepCopy();
- node->mParent->addChild(cloned_node, node); // add after node
- LLXMLNodePtr parent = node->mParent;
- parent->removeChild(node);
- parent->updateDefault();
-
- return cloned_node;
-}
-
-
-
// static
bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXMLNode* defaults_tree)
{
@@ -693,7 +658,7 @@ bool LLXMLNode::parseFile(const std::string& filename, LLXMLNodePtr& node, LLXML
LLFILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
if (fp == NULL)
{
- node = new LLXMLNode();
+ node = NULL ;
return false;
}
fseek(fp, 0, SEEK_END);
@@ -733,10 +698,10 @@ bool LLXMLNode::parseBuffer(
// Do the parsing
if (XML_Parse(my_parser, (const char *)buffer, length, TRUE) != XML_STATUS_OK)
{
- llwarns << "Error parsing xml error code: "
+ LL_WARNS() << "Error parsing xml error code: "
<< XML_ErrorString(XML_GetErrorCode(my_parser))
<< " on line " << XML_GetCurrentLineNumber(my_parser)
- << llendl;
+ << LL_ENDL;
}
// Deinit
@@ -744,9 +709,9 @@ bool LLXMLNode::parseBuffer(
if (!file_node->mChildren || file_node->mChildren->map.size() != 1)
{
- llwarns << "Parse failure - wrong number of top-level nodes xml."
- << llendl;
- node = new LLXMLNode();
+ LL_WARNS() << "Parse failure - wrong number of top-level nodes xml."
+ << LL_ENDL;
+ node = NULL ;
return false;
}
@@ -784,14 +749,14 @@ bool LLXMLNode::parseStream(
while(str.good())
{
str.read((char*)buffer, BUFSIZE);
- int count = str.gcount();
+ int count = (int)str.gcount();
if (XML_Parse(my_parser, (const char *)buffer, count, !str.good()) != XML_STATUS_OK)
{
- llwarns << "Error parsing xml error code: "
+ LL_WARNS() << "Error parsing xml error code: "
<< XML_ErrorString(XML_GetErrorCode(my_parser))
<< " on lne " << XML_GetCurrentLineNumber(my_parser)
- << llendl;
+ << LL_ENDL;
break;
}
}
@@ -803,9 +768,9 @@ bool LLXMLNode::parseStream(
if (!file_node->mChildren || file_node->mChildren->map.size() != 1)
{
- llwarns << "Parse failure - wrong number of top-level nodes xml."
- << llendl;
- node = new LLXMLNode();
+ LL_WARNS() << "Parse failure - wrong number of top-level nodes xml."
+ << LL_ENDL;
+ node = NULL;
return false;
}
@@ -859,36 +824,32 @@ BOOL LLXMLNode::isFullyDefault()
}
// static
-bool LLXMLNode::getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr& root,
+bool LLXMLNode::getLayeredXMLNode(LLXMLNodePtr& root,
const std::vector<std::string>& paths)
{
- std::string full_filename = gDirUtilp->findSkinnedFilename(paths.front(), xui_filename);
- if (full_filename.empty())
+ if (paths.empty()) return false;
+
+ std::string filename = paths.front();
+ if (filename.empty())
{
return false;
}
-
- if (!LLXMLNode::parseFile(full_filename, root, NULL))
+
+ if (!LLXMLNode::parseFile(filename, root, NULL))
{
- // try filename as passed in since sometimes we load an xml file from a user-supplied path
- if (!LLXMLNode::parseFile(xui_filename, root, NULL))
- {
- llwarns << "Problem reading UI description file: " << xui_filename << llendl;
- return false;
- }
+ LL_WARNS() << "Problem reading UI description file: " << filename << LL_ENDL;
+ return false;
}
LLXMLNodePtr updateRoot;
std::vector<std::string>::const_iterator itor;
- for (itor = paths.begin(), ++itor; itor != paths.end(); ++itor)
+ // We've already dealt with the first item, skip that one
+ for (itor = paths.begin() + 1; itor != paths.end(); ++itor)
{
- std::string nodeName;
- std::string updateName;
-
- std::string layer_filename = gDirUtilp->findSkinnedFilename((*itor), xui_filename);
- if(layer_filename.empty())
+ std::string layer_filename = *itor;
+ if(layer_filename.empty() || layer_filename == filename)
{
// no localized version of this file, that's ok, keep looking
continue;
@@ -896,10 +857,13 @@ bool LLXMLNode::getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr&
if (!LLXMLNode::parseFile(layer_filename, updateRoot, NULL))
{
- llwarns << "Problem reading localized UI description file: " << (*itor) + gDirUtilp->getDirDelimiter() + xui_filename << llendl;
+ LL_WARNS() << "Problem reading localized UI description file: " << layer_filename << LL_ENDL;
return false;
}
+ std::string nodeName;
+ std::string updateName;
+
updateRoot->getAttributeString("name", updateName);
root->getAttributeString("name", nodeName);
@@ -932,7 +896,7 @@ void LLXMLNode::writeToFile(LLFILE *out_file, const std::string& indent, bool us
size_t written = fwrite(outstring.c_str(), 1, outstring.length(), out_file);
if (written != outstring.length())
{
- llwarns << "Short write" << llendl;
+ LL_WARNS() << "Short write" << LL_ENDL;
}
}
@@ -1183,7 +1147,8 @@ void LLXMLNode::scrubToTree(LLXMLNode *tree)
std::vector<LLXMLNodePtr>::iterator itor3;
for (itor3=to_delete_list.begin(); itor3!=to_delete_list.end(); ++itor3)
{
- (*itor3)->setParent(NULL);
+ LLXMLNodePtr ptr;
+ (*itor3)->setParent(ptr);
}
}
}
@@ -1208,7 +1173,7 @@ bool LLXMLNode::getChild(const LLStringTableEntry* name, LLXMLNodePtr& node, BOO
{
return mDefault->getChild(name, node, FALSE);
}
- node = new LLXMLNode();
+ node = NULL;
return false;
}
@@ -1279,7 +1244,7 @@ bool LLXMLNode::getAttribute(const LLStringTableEntry* name, LLXMLNodePtr& node,
{
return mDefault->getAttribute(name, node, FALSE);
}
- node = new LLXMLNode();
+
return false;
}
@@ -1768,9 +1733,9 @@ U32 LLXMLNode::getBoolValue(U32 expected_length, BOOL *array)
#if LL_DEBUG
if (ret_length != expected_length)
{
- lldebugs << "LLXMLNode::getBoolValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getBoolValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << ret_length << llendl;
+ << "only found " << ret_length << LL_ENDL;
}
#endif
return ret_length;
@@ -1789,8 +1754,8 @@ U32 LLXMLNode::getByteValue(U32 expected_length, U8 *array, Encoding encoding)
if (mLength > 0 && mLength != expected_length)
{
- llwarns << "XMLNode::getByteValue asked for " << expected_length
- << " elements, while node has " << mLength << llendl;
+ LL_WARNS() << "XMLNode::getByteValue asked for " << expected_length
+ << " elements, while node has " << mLength << LL_ENDL;
return 0;
}
@@ -1813,7 +1778,7 @@ U32 LLXMLNode::getByteValue(U32 expected_length, U8 *array, Encoding encoding)
}
if (value > 255 || is_negative)
{
- llwarns << "getByteValue: Value outside of valid range." << llendl;
+ LL_WARNS() << "getByteValue: Value outside of valid range." << LL_ENDL;
break;
}
array[i] = U8(value);
@@ -1821,9 +1786,9 @@ U32 LLXMLNode::getByteValue(U32 expected_length, U8 *array, Encoding encoding)
#if LL_DEBUG
if (i != expected_length)
{
- lldebugs << "LLXMLNode::getByteValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getByteValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << i << llendl;
+ << "only found " << i << LL_ENDL;
}
#endif
return i;
@@ -1841,8 +1806,8 @@ U32 LLXMLNode::getIntValue(U32 expected_length, S32 *array, Encoding encoding)
if (mLength > 0 && mLength != expected_length)
{
- llwarns << "XMLNode::getIntValue asked for " << expected_length
- << " elements, while node has " << mLength << llendl;
+ LL_WARNS() << "XMLNode::getIntValue asked for " << expected_length
+ << " elements, while node has " << mLength << LL_ENDL;
return 0;
}
@@ -1865,7 +1830,7 @@ U32 LLXMLNode::getIntValue(U32 expected_length, S32 *array, Encoding encoding)
}
if (value > 0x7fffffff)
{
- llwarns << "getIntValue: Value outside of valid range." << llendl;
+ LL_WARNS() << "getIntValue: Value outside of valid range." << LL_ENDL;
break;
}
array[i] = S32(value) * (is_negative?-1:1);
@@ -1874,9 +1839,9 @@ U32 LLXMLNode::getIntValue(U32 expected_length, S32 *array, Encoding encoding)
#if LL_DEBUG
if (i != expected_length)
{
- lldebugs << "LLXMLNode::getIntValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getIntValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << i << llendl;
+ << "only found " << i << LL_ENDL;
}
#endif
return i;
@@ -1894,8 +1859,8 @@ U32 LLXMLNode::getUnsignedValue(U32 expected_length, U32 *array, Encoding encodi
if (mLength > 0 && mLength != expected_length)
{
- llwarns << "XMLNode::getUnsignedValue asked for " << expected_length
- << " elements, while node has " << mLength << llendl;
+ LL_WARNS() << "XMLNode::getUnsignedValue asked for " << expected_length
+ << " elements, while node has " << mLength << LL_ENDL;
return 0;
}
@@ -1919,7 +1884,7 @@ U32 LLXMLNode::getUnsignedValue(U32 expected_length, U32 *array, Encoding encodi
}
if (is_negative || value > 0xffffffff)
{
- llwarns << "getUnsignedValue: Value outside of valid range." << llendl;
+ LL_WARNS() << "getUnsignedValue: Value outside of valid range." << LL_ENDL;
break;
}
array[i] = U32(value);
@@ -1928,9 +1893,9 @@ U32 LLXMLNode::getUnsignedValue(U32 expected_length, U32 *array, Encoding encodi
#if LL_DEBUG
if (i != expected_length)
{
- lldebugs << "LLXMLNode::getUnsignedValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getUnsignedValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << i << llendl;
+ << "only found " << i << LL_ENDL;
}
#endif
@@ -1949,7 +1914,7 @@ U32 LLXMLNode::getLongValue(U32 expected_length, U64 *array, Encoding encoding)
if (mLength > 0 && mLength != expected_length)
{
- llwarns << "XMLNode::getLongValue asked for " << expected_length << " elements, while node has " << mLength << llendl;
+ LL_WARNS() << "XMLNode::getLongValue asked for " << expected_length << " elements, while node has " << mLength << LL_ENDL;
return 0;
}
@@ -1973,7 +1938,7 @@ U32 LLXMLNode::getLongValue(U32 expected_length, U64 *array, Encoding encoding)
}
if (is_negative)
{
- llwarns << "getLongValue: Value outside of valid range." << llendl;
+ LL_WARNS() << "getLongValue: Value outside of valid range." << LL_ENDL;
break;
}
array[i] = value;
@@ -1982,9 +1947,9 @@ U32 LLXMLNode::getLongValue(U32 expected_length, U64 *array, Encoding encoding)
#if LL_DEBUG
if (i != expected_length)
{
- lldebugs << "LLXMLNode::getLongValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getLongValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << i << llendl;
+ << "only found " << i << LL_ENDL;
}
#endif
@@ -2003,7 +1968,7 @@ U32 LLXMLNode::getFloatValue(U32 expected_length, F32 *array, Encoding encoding)
if (mLength > 0 && mLength != expected_length)
{
- llwarns << "XMLNode::getFloatValue asked for " << expected_length << " elements, while node has " << mLength << llendl;
+ LL_WARNS() << "XMLNode::getFloatValue asked for " << expected_length << " elements, while node has " << mLength << LL_ENDL;
return 0;
}
@@ -2028,9 +1993,9 @@ U32 LLXMLNode::getFloatValue(U32 expected_length, F32 *array, Encoding encoding)
#if LL_DEBUG
if (i != expected_length)
{
- lldebugs << "LLXMLNode::getFloatValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getFloatValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << i << llendl;
+ << "only found " << i << LL_ENDL;
}
#endif
return i;
@@ -2048,7 +2013,7 @@ U32 LLXMLNode::getDoubleValue(U32 expected_length, F64 *array, Encoding encoding
if (mLength > 0 && mLength != expected_length)
{
- llwarns << "XMLNode::getDoubleValue asked for " << expected_length << " elements, while node has " << mLength << llendl;
+ LL_WARNS() << "XMLNode::getDoubleValue asked for " << expected_length << " elements, while node has " << mLength << LL_ENDL;
return 0;
}
@@ -2073,9 +2038,9 @@ U32 LLXMLNode::getDoubleValue(U32 expected_length, F64 *array, Encoding encoding
#if LL_DEBUG
if (i != expected_length)
{
- lldebugs << "LLXMLNode::getDoubleValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getDoubleValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << i << llendl;
+ << "only found " << i << LL_ENDL;
}
#endif
return i;
@@ -2089,7 +2054,7 @@ U32 LLXMLNode::getStringValue(U32 expected_length, std::string *array)
if (mLength > 0 && mLength != expected_length)
{
- llwarns << "XMLNode::getStringValue asked for " << expected_length << " elements, while node has " << mLength << llendl;
+ LL_WARNS() << "XMLNode::getStringValue asked for " << expected_length << " elements, while node has " << mLength << LL_ENDL;
return 0;
}
@@ -2121,9 +2086,9 @@ U32 LLXMLNode::getStringValue(U32 expected_length, std::string *array)
#if LL_DEBUG
if (num_returned_strings != expected_length)
{
- lldebugs << "LLXMLNode::getStringValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getStringValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << num_returned_strings << llendl;
+ << "only found " << num_returned_strings << LL_ENDL;
}
#endif
@@ -2166,9 +2131,9 @@ U32 LLXMLNode::getUUIDValue(U32 expected_length, LLUUID *array)
#if LL_DEBUG
if (i != expected_length)
{
- lldebugs << "LLXMLNode::getUUIDValue() failed for node named '"
+ LL_DEBUGS() << "LLXMLNode::getUUIDValue() failed for node named '"
<< mName->mString << "' -- expected " << expected_length << " but "
- << "only found " << i << llendl;
+ << "only found " << i << LL_ENDL;
}
#endif
return i;
@@ -2197,11 +2162,11 @@ U32 LLXMLNode::getNodeRefValue(U32 expected_length, LLXMLNode **array)
root->findID(string_array[strnum], node_list);
if (node_list.empty())
{
- llwarns << "XML: Could not find node ID: " << string_array[strnum] << llendl;
+ LL_WARNS() << "XML: Could not find node ID: " << string_array[strnum] << LL_ENDL;
}
else if (node_list.size() > 1)
{
- llwarns << "XML: Node ID not unique: " << string_array[strnum] << llendl;
+ LL_WARNS() << "XML: Node ID not unique: " << string_array[strnum] << LL_ENDL;
}
else
{
@@ -2718,7 +2683,8 @@ void LLXMLNode::setName(LLStringTableEntry* name)
mName = name;
if (old_parent)
{
- old_parent->addChild(this);
+ LLXMLNodePtr this_ptr(this);
+ old_parent->addChild(this_ptr);
}
}
diff --git a/indra/llxml/llxmlnode.h b/indra/llxml/llxmlnode.h
index 9df37ccb6f..0b8da5dc5d 100644..100755
--- a/indra/llxml/llxmlnode.h
+++ b/indra/llxml/llxmlnode.h
@@ -30,7 +30,7 @@
#ifndef XML_STATIC
#define XML_STATIC
#endif
-#ifdef LL_STANDALONE
+#ifdef LL_USESYSTEMLIBS
#include <expat.h>
#else
#include "expat/expat.h"
@@ -38,17 +38,16 @@
#include <map>
#include "indra_constants.h"
+#include "llrefcount.h"
#include "llpointer.h"
-#include "llthread.h" // LLThreadSafeRefCount
#include "llstring.h"
#include "llstringtable.h"
#include "llfile.h"
-
+#include "lluuid.h"
class LLVector3;
class LLVector3d;
class LLQuaternion;
-class LLUUID;
class LLColor4;
class LLColor4U;
@@ -127,8 +126,8 @@ public:
BOOL isNull();
BOOL deleteChild(LLXMLNode* child);
- void addChild(LLXMLNodePtr new_child, LLXMLNodePtr after_child = LLXMLNodePtr(NULL));
- void setParent(LLXMLNodePtr new_parent); // reparent if necessary
+ void addChild(LLXMLNodePtr& new_child);
+ void setParent(LLXMLNodePtr& new_parent); // reparent if necessary
// Serialization
static bool parseFile(
@@ -147,10 +146,8 @@ public:
static bool updateNode(
LLXMLNodePtr& node,
LLXMLNodePtr& update_node);
- static LLXMLNodePtr replaceNode(LLXMLNodePtr node, LLXMLNodePtr replacement_node);
- static bool getLayeredXMLNode(const std::string &xui_filename, LLXMLNodePtr& root,
- const std::vector<std::string>& paths);
+ static bool getLayeredXMLNode(LLXMLNodePtr& root, const std::vector<std::string>& paths);
// Write standard XML file header:
diff --git a/indra/llxml/llxmlparser.cpp b/indra/llxml/llxmlparser.cpp
index 7db4a90b57..1bdc283f67 100644..100755
--- a/indra/llxml/llxmlparser.cpp
+++ b/indra/llxml/llxmlparser.cpp
@@ -121,7 +121,7 @@ exit_label:
if( !success )
{
- llwarns << mAuxErrorString << llendl;
+ LL_WARNS() << mAuxErrorString << LL_ENDL;
}
return success;
diff --git a/indra/llxml/llxmlparser.h b/indra/llxml/llxmlparser.h
index e0f8b69452..a5b210404f 100644..100755
--- a/indra/llxml/llxmlparser.h
+++ b/indra/llxml/llxmlparser.h
@@ -30,7 +30,7 @@
#ifndef XML_STATIC
#define XML_STATIC
#endif
-#ifdef LL_STANDALONE
+#ifdef LL_USESYSTEMLIBS
#include <expat.h>
#else
#include "expat/expat.h"
diff --git a/indra/llxml/llxmltree.cpp b/indra/llxml/llxmltree.cpp
index f2386700a1..ca98953f92 100644..100755
--- a/indra/llxml/llxmltree.cpp
+++ b/indra/llxml/llxmltree.cpp
@@ -72,7 +72,7 @@ BOOL LLXmlTree::parseFile(const std::string &path, BOOL keep_contents)
{
S32 line_number = parser.getCurrentLineNumber();
const char* error = parser.getErrorString();
- llwarns << "LLXmlTree parse failed. Line " << line_number << ": " << error << llendl;
+ LL_WARNS() << "LLXmlTree parse failed. Line " << line_number << ": " << error << LL_ENDL;
}
return success;
}
@@ -118,19 +118,19 @@ LLXmlTreeNode::~LLXmlTreeNode()
void LLXmlTreeNode::dump( const std::string& prefix )
{
- llinfos << prefix << mName ;
+ LL_INFOS() << prefix << mName ;
if( !mContents.empty() )
{
- llcont << " contents = \"" << mContents << "\"";
+ LL_CONT << " contents = \"" << mContents << "\"";
}
attribute_map_t::iterator iter;
for (iter=mAttributes.begin(); iter != mAttributes.end(); iter++)
{
LLStdStringHandle key = iter->first;
const std::string* value = iter->second;
- llcont << prefix << " " << key << "=" << (value->empty() ? "NULL" : *value);
+ LL_CONT << prefix << " " << key << "=" << (value->empty() ? "NULL" : *value);
}
- llcont << llendl;
+ LL_CONT << LL_ENDL;
}
BOOL LLXmlTreeNode::hasAttribute(const std::string& name)
@@ -551,12 +551,12 @@ void LLXmlTreeParser::startElement(const char* name, const char **atts)
{
if( mDump )
{
- llinfos << tabs() << "startElement " << name << llendl;
+ LL_INFOS() << tabs() << "startElement " << name << LL_ENDL;
S32 i = 0;
while( atts[i] && atts[i+1] )
{
- llinfos << tabs() << "attribute: " << atts[i] << "=" << atts[i+1] << llendl;
+ LL_INFOS() << tabs() << "attribute: " << atts[i] << "=" << atts[i+1] << LL_ENDL;
i += 2;
}
}
@@ -593,7 +593,7 @@ void LLXmlTreeParser::endElement(const char* name)
{
if( mDump )
{
- llinfos << tabs() << "endElement " << name << llendl;
+ LL_INFOS() << tabs() << "endElement " << name << LL_ENDL;
}
if( !mCurrent->mContents.empty() )
@@ -611,7 +611,7 @@ void LLXmlTreeParser::characterData(const char *s, int len)
if (s) str = std::string(s, len);
if( mDump )
{
- llinfos << tabs() << "CharacterData " << str << llendl;
+ LL_INFOS() << tabs() << "CharacterData " << str << LL_ENDL;
}
if (mKeepContents)
@@ -624,7 +624,7 @@ void LLXmlTreeParser::processingInstruction(const char *target, const char *data
{
if( mDump )
{
- llinfos << tabs() << "processingInstruction " << data << llendl;
+ LL_INFOS() << tabs() << "processingInstruction " << data << LL_ENDL;
}
}
@@ -632,7 +632,7 @@ void LLXmlTreeParser::comment(const char *data)
{
if( mDump )
{
- llinfos << tabs() << "comment " << data << llendl;
+ LL_INFOS() << tabs() << "comment " << data << LL_ENDL;
}
}
@@ -640,7 +640,7 @@ void LLXmlTreeParser::startCdataSection()
{
if( mDump )
{
- llinfos << tabs() << "startCdataSection" << llendl;
+ LL_INFOS() << tabs() << "startCdataSection" << LL_ENDL;
}
}
@@ -648,7 +648,7 @@ void LLXmlTreeParser::endCdataSection()
{
if( mDump )
{
- llinfos << tabs() << "endCdataSection" << llendl;
+ LL_INFOS() << tabs() << "endCdataSection" << LL_ENDL;
}
}
@@ -658,7 +658,7 @@ void LLXmlTreeParser::defaultData(const char *s, int len)
{
std::string str;
if (s) str = std::string(s, len);
- llinfos << tabs() << "defaultData " << str << llendl;
+ LL_INFOS() << tabs() << "defaultData " << str << LL_ENDL;
}
}
@@ -671,12 +671,12 @@ void LLXmlTreeParser::unparsedEntityDecl(
{
if( mDump )
{
- llinfos << tabs() << "unparsed entity:" << llendl;
- llinfos << tabs() << " entityName " << entity_name << llendl;
- llinfos << tabs() << " base " << base << llendl;
- llinfos << tabs() << " systemId " << system_id << llendl;
- llinfos << tabs() << " publicId " << public_id << llendl;
- llinfos << tabs() << " notationName " << notation_name<< llendl;
+ LL_INFOS() << tabs() << "unparsed entity:" << LL_ENDL;
+ LL_INFOS() << tabs() << " entityName " << entity_name << LL_ENDL;
+ LL_INFOS() << tabs() << " base " << base << LL_ENDL;
+ LL_INFOS() << tabs() << " systemId " << system_id << LL_ENDL;
+ LL_INFOS() << tabs() << " publicId " << public_id << LL_ENDL;
+ LL_INFOS() << tabs() << " notationName " << notation_name<< LL_ENDL;
}
}
diff --git a/indra/llxml/llxmltree.h b/indra/llxml/llxmltree.h
index bdcb56f1f3..a82fee0416 100644..100755
--- a/indra/llxml/llxmltree.h
+++ b/indra/llxml/llxmltree.h
@@ -32,7 +32,7 @@
#include <list>
#include "llstring.h"
#include "llxmlparser.h"
-#include "string_table.h"
+#include "llstringtable.h"
class LLColor4;
class LLColor4U;
@@ -227,7 +227,7 @@ protected:
LLXmlTree* mTree;
LLXmlTreeNode* mRoot;
LLXmlTreeNode* mCurrent;
- BOOL mDump; // Dump parse tree to llinfos as it is read.
+ BOOL mDump; // Dump parse tree to LL_INFOS() as it is read.
BOOL mKeepContents;
};
diff --git a/indra/llxml/tests/llcontrol_test.cpp b/indra/llxml/tests/llcontrol_test.cpp
index ede81956ec..2b691ffbb1 100644..100755
--- a/indra/llxml/tests/llcontrol_test.cpp
+++ b/indra/llxml/tests/llcontrol_test.cpp
@@ -80,7 +80,7 @@ namespace tut
}
void writeSettingsFile(const LLSD& config)
{
- llofstream file(mTestConfigFile);
+ llofstream file(mTestConfigFile.c_str());
if (file.is_open())
{
LLSDSerialize::toPrettyXML(config, file);
@@ -128,7 +128,11 @@ namespace tut
template<> template<>
void control_group_t::test<3>()
{
- int results = mCG->loadFromFile(mTestConfigFile.c_str());
+ // Pass default_values = true. This tells loadFromFile() we're loading
+ // a default settings file that declares variables, rather than a user
+ // settings file. When loadFromFile() encounters an unrecognized user
+ // settings variable, it forcibly preserves it (CHOP-962).
+ int results = mCG->loadFromFile(mTestConfigFile.c_str(), true);
LLControlVariable* control = mCG->getControl("TestSetting");
LLSD new_value = 13;
control->setValue(new_value, FALSE);