From 2a4dea528f670b9bb1f77ef27a8a1dd16603d114 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:50 -0500 Subject: Second Life viewer sources 1.20.7 --- linden/indra/llxml/llcontrol.cpp | 71 +++++++++++++++++++++++++++----------- linden/indra/llxml/llcontrol.h | 2 +- linden/indra/llxml/llxmlnode.cpp | 6 ++-- linden/indra/llxml/llxmlnode.h | 8 +++-- linden/indra/llxml/llxmlparser.cpp | 4 +-- linden/indra/llxml/llxmlparser.h | 4 ++- 6 files changed, 65 insertions(+), 30 deletions(-) (limited to 'linden/indra/llxml') diff --git a/linden/indra/llxml/llcontrol.cpp b/linden/indra/llxml/llcontrol.cpp index 8c74127..09719a5 100644 --- a/linden/indra/llxml/llcontrol.cpp +++ b/linden/indra/llxml/llcontrol.cpp @@ -50,44 +50,53 @@ #include "llsdserialize.h" #if LL_RELEASE_FOR_DOWNLOAD -#define CONTROL_ERRS llwarns +#define CONTROL_ERRS LL_WARNS("ControlErrors") #else -#define CONTROL_ERRS llerrs +#define CONTROL_ERRS LL_ERRS("ControlErrors") #endif //this defines the current version of the settings file const S32 CURRENT_VERSION = 101; -BOOL LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) +bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b) { + bool result = false; switch (mType) { case TYPE_U32: case TYPE_S32: - return a.asInteger() == b.asInteger(); + result = a.asInteger() == b.asInteger(); + break; case TYPE_BOOLEAN: - return a.asBoolean() == b.asBoolean(); + result = a.asBoolean() == b.asBoolean(); + break; case TYPE_F32: - return a.asReal() == b.asReal(); + result = a.asReal() == b.asReal(); + break; case TYPE_VEC3: case TYPE_VEC3D: - return LLVector3d(a) == LLVector3d(b); + result = LLVector3d(a) == LLVector3d(b); + break; case TYPE_RECT: - return LLRect(a) == LLRect(b); + result = LLRect(a) == LLRect(b); + break; case TYPE_COL4: - return LLColor4(a) == LLColor4(b); + result = LLColor4(a) == LLColor4(b); + break; case TYPE_COL3: - return LLColor3(a) == LLColor3(b); + result = LLColor3(a) == LLColor3(b); + break; case TYPE_COL4U: - return LLColor4U(a) == LLColor4U(b); + result = LLColor4U(a) == LLColor4U(b); + break; case TYPE_STRING: - return a.asString() == b.asString(); + result = a.asString() == b.asString(); + break; default: - // no-op break; } - return FALSE; + return result; } LLControlVariable::LLControlVariable(const LLString& name, eControlType type, @@ -114,14 +123,34 @@ LLControlVariable::~LLControlVariable() void LLControlVariable::setValue(const LLSD& value, bool saved_value) { - bool value_changed = llsd_compare(getValue(), value) == FALSE; + // *FIX:MEP - The following is needed to make the LLSD::ImplString + // work with boolean controls... + LLSD storable_value; + if(TYPE_BOOLEAN == type() && value.isString()) + { + BOOL temp; + if(LLString::convertToBOOL(value.asString(), temp)) + { + storable_value = temp; + } + else + { + storable_value = FALSE; + } + } + else + { + storable_value = value; + } + + bool value_changed = llsd_compare(getValue(), storable_value) == FALSE; if(saved_value) { // If we're going to save this value, return to default but don't fire resetToDefault(false); - if (llsd_compare(mValues.back(), value) == FALSE) + if (llsd_compare(mValues.back(), storable_value) == FALSE) { - mValues.push_back(value); + mValues.push_back(storable_value); } } else @@ -129,7 +158,7 @@ void LLControlVariable::setValue(const LLSD& value, bool saved_value) // This is a unsaved value. Its needs to reside at // mValues[2] (or greater). It must not affect // the result of getSaveValue() - if (llsd_compare(mValues.back(), value) == FALSE) + if (llsd_compare(mValues.back(), storable_value) == FALSE) { while(mValues.size() > 2) { @@ -144,13 +173,14 @@ void LLControlVariable::setValue(const LLSD& value, bool saved_value) } // Add the 'un-save' value. - mValues.push_back(value); + mValues.push_back(storable_value); } } + if(value_changed) { - mSignal(value); + mSignal(storable_value); } } @@ -1147,3 +1177,4 @@ void main() #endif + diff --git a/linden/indra/llxml/llcontrol.h b/linden/indra/llxml/llcontrol.h index 2511940..91545ce 100644 --- a/linden/indra/llxml/llcontrol.h +++ b/linden/indra/llxml/llcontrol.h @@ -127,7 +127,7 @@ public: { mSignal(mValues.back()); } - BOOL llsd_compare(const LLSD& a, const LLSD& b); + bool llsd_compare(const LLSD& a, const LLSD& b); }; //const U32 STRING_CACHE_SIZE = 10000; diff --git a/linden/indra/llxml/llxmlnode.cpp b/linden/indra/llxml/llxmlnode.cpp index 757e2f7..f9852d3 100644 --- a/linden/indra/llxml/llxmlnode.cpp +++ b/linden/indra/llxml/llxmlnode.cpp @@ -572,7 +572,7 @@ bool LLXMLNode::parseFile( LLXMLNode* defaults_tree) { // Read file - FILE* fp = LLFile::fopen(filename.c_str(), "rb"); /* Flawfinder: ignore */ + LLFILE* fp = LLFile::fopen(filename.c_str(), "rb"); /* Flawfinder: ignore */ if (fp == NULL) { node = new LLXMLNode(); @@ -741,12 +741,12 @@ BOOL LLXMLNode::isFullyDefault() } // static -void LLXMLNode::writeHeaderToFile(FILE *fOut) +void LLXMLNode::writeHeaderToFile(LLFILE *fOut) { fprintf(fOut, "\n"); } -void LLXMLNode::writeToFile(FILE *fOut, LLString indent) +void LLXMLNode::writeToFile(LLFILE *fOut, LLString indent) { if (isFullyDefault()) { diff --git a/linden/indra/llxml/llxmlnode.h b/linden/indra/llxml/llxmlnode.h index 6183ec1..269108c 100644 --- a/linden/indra/llxml/llxmlnode.h +++ b/linden/indra/llxml/llxmlnode.h @@ -32,7 +32,9 @@ #ifndef LL_LLXMLNODE_H #define LL_LLXMLNODE_H -#define XML_STATIC +#ifndef XML_STATIC +#define XML_STATIC 1 +#endif #ifdef LL_STANDALONE #include #else @@ -131,8 +133,8 @@ public: static bool updateNode( LLXMLNodePtr& node, LLXMLNodePtr& update_node); - static void writeHeaderToFile(FILE *fOut); - void writeToFile(FILE *fOut, LLString indent = LLString()); + static void writeHeaderToFile(LLFILE *fOut); + void writeToFile(LLFILE *fOut, LLString indent = LLString()); void writeToOstream(std::ostream& output_stream, const LLString& indent = LLString()); // Utility diff --git a/linden/indra/llxml/llxmlparser.cpp b/linden/indra/llxml/llxmlparser.cpp index 0cbb82b..3b4d944 100644 --- a/linden/indra/llxml/llxmlparser.cpp +++ b/linden/indra/llxml/llxmlparser.cpp @@ -77,7 +77,7 @@ BOOL LLXmlParser::parseFile(const std::string &path) BOOL success = TRUE; - FILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */ + LLFILE* file = LLFile::fopen(path.c_str(), "rb"); /* Flawfinder: ignore */ if( !file ) { snprintf( mAuxErrorString, sizeof(mAuxErrorString), "Couldn't open file %s", path.c_str()); /* Flawfinder: ignore */ @@ -393,7 +393,7 @@ int main() { char buf[1024]; - FILE* file = LLFile::fopen("test.xml", "rb"); + LLFILE* file = LLFile::fopen("test.xml", "rb"); if( !file ) { return 1; diff --git a/linden/indra/llxml/llxmlparser.h b/linden/indra/llxml/llxmlparser.h index 611605f..7ce5524 100644 --- a/linden/indra/llxml/llxmlparser.h +++ b/linden/indra/llxml/llxmlparser.h @@ -32,7 +32,9 @@ #ifndef LL_LLXMLPARSER_H #define LL_LLXMLPARSER_H -#define XML_STATIC +#ifndef XML_STATIC +#define XML_STATIC 1 +#endif #ifdef LL_STANDALONE #include #else -- cgit v1.1