diff options
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llerror.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/llerror.h | 14 | ||||
-rw-r--r-- | indra/llcommon/llinstancetracker.h | 2 | ||||
-rw-r--r-- | indra/llcommon/llsdserialize.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/llsdserialize_xml.cpp | 23 | ||||
-rw-r--r-- | indra/llcommon/llsingleton.h | 20 | ||||
-rwxr-xr-x | indra/llcommon/llversionviewer.h | 2 | ||||
-rw-r--r-- | indra/llcommon/tests/llinstancetracker_test.cpp | 144 |
8 files changed, 109 insertions, 100 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index bb64152407..c35799bbb9 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -379,7 +379,7 @@ namespace { /* This pattern, of returning a reference to a static function variable, is to ensure that this global is constructed before - it is used, no matter what the global initializeation sequence + it is used, no matter what the global initialization sequence is. See C++ FAQ Lite, sections 10.12 through 10.14 */ diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h index 4a42241c4f..b3e604f8e8 100644 --- a/indra/llcommon/llerror.h +++ b/indra/llcommon/llerror.h @@ -39,7 +39,7 @@ Information for most users: - Code can log messages with constuctions like this: + Code can log messages with constructions like this: LL_INFOS("StringTag") << "request to fizzbip agent " << agent_id << " denied due to timeout" << LL_ENDL; @@ -47,9 +47,9 @@ Messages can be logged to one of four increasing levels of concern, using one of four "streams": - LL_DEBUGS("StringTag") - debug messages that are normally supressed - LL_INFOS("StringTag") - informational messages that are normall shown - LL_WARNS("StringTag") - warning messages that singal a problem + LL_DEBUGS("StringTag") - debug messages that are normally suppressed + LL_INFOS("StringTag") - informational messages that are normal shown + LL_WARNS("StringTag") - warning messages that signal a problem LL_ERRS("StringTag") - error messages that are major, unrecoverable failures The later (LL_ERRS("StringTag")) automatically crashes the process after the message @@ -90,7 +90,7 @@ WARN: LLFoo::doSomething: called with a big value for i: 283 - Which messages are logged and which are supressed can be controled at run + Which messages are logged and which are suppressed can be controlled at run time from the live file logcontrol.xml based on function, class and/or source file. See etc/logcontrol-dev.xml for details. @@ -106,7 +106,7 @@ namespace LLError enum ELevel { LEVEL_ALL = 0, - // used to indicate that all messagess should be logged + // used to indicate that all messages should be logged LEVEL_DEBUG = 0, LEVEL_INFO = 1, @@ -220,7 +220,7 @@ namespace LLError // See top of file for example of how to use this typedef LLError::NoClassInfo _LL_CLASS_TO_LOG; - // Outside a class declartion, or in class without LOG_CLASS(), this + // Outside a class declaration, or in class without LOG_CLASS(), this // typedef causes the messages to not be associated with any class. diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index b4891eba67..afb714c71c 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -92,7 +92,7 @@ public: public: typedef boost::iterator_facade<key_iter, KEY, boost::forward_traversal_tag> super_t; - key_iter(typename InstanceMap::iterator& it) + key_iter(typename InstanceMap::iterator it) : mIterator(it) { ++sIterationNestDepth; diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index 6610daa1e0..bf62600514 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -313,10 +313,8 @@ LLSDParser::LLSDParser() LLSDParser::~LLSDParser() { } -LLFastTimer::DeclareTimer FTM_SD_PARSE("LLSD Parsing"); S32 LLSDParser::parse(std::istream& istr, LLSD& data, S32 max_bytes) { - LLFastTimer _(FTM_SD_PARSE); mCheckLimits = (LLSDSerialize::SIZE_UNLIMITED == max_bytes) ? false : true; mMaxBytesLeft = max_bytes; return doParse(istr, data); diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp index d8213c4477..bf216d41bf 100644 --- a/indra/llcommon/llsdserialize_xml.cpp +++ b/indra/llcommon/llsdserialize_xml.cpp @@ -720,6 +720,7 @@ void LLSDXMLParser::Impl::endElementHandler(const XML_Char* name) case ELEMENT_INTEGER: { S32 i; + // sscanf okay here with different locales - ints don't change for different locale settings like floats do. if ( sscanf(mCurrentContent.c_str(), "%d", &i ) == 1 ) { // See if sscanf works - it's faster value = i; @@ -733,15 +734,19 @@ void LLSDXMLParser::Impl::endElementHandler(const XML_Char* name) case ELEMENT_REAL: { - F64 r; - if ( sscanf(mCurrentContent.c_str(), "%lf", &r ) == 1 ) - { // See if sscanf works - it's faster - value = r; - } - else - { - value = LLSD(mCurrentContent).asReal(); - } + value = LLSD(mCurrentContent).asReal(); + // removed since this breaks when locale has decimal separator that isn't '.' + // investigated changing local to something compatible each time but deemed higher + // risk that just using LLSD.asReal() each time. + //F64 r; + //if ( sscanf(mCurrentContent.c_str(), "%lf", &r ) == 1 ) + //{ // See if sscanf works - it's faster + // value = r; + //} + //else + //{ + // value = LLSD(mCurrentContent).asReal(); + //} } break; diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h index 7aee1bb85f..00757be277 100644 --- a/indra/llcommon/llsingleton.h +++ b/indra/llcommon/llsingleton.h @@ -100,12 +100,6 @@ private: DELETED } EInitState; - static void deleteSingleton() - { - delete getData().mSingletonInstance; - getData().mSingletonInstance = NULL; - } - // stores pointer to singleton instance // and tracks initialization state of singleton struct SingletonInstanceData @@ -120,7 +114,11 @@ private: ~SingletonInstanceData() { - deleteSingleton(); + SingletonInstanceData& data = getData(); + if (data.mInitState != DELETED) + { + deleteSingleton(); + } } }; @@ -132,6 +130,14 @@ public: data.mInitState = DELETED; } + // Can be used to control when the singleton is deleted. Not normally needed. + static void deleteSingleton() + { + delete getData().mSingletonInstance; + getData().mSingletonInstance = NULL; + getData().mInitState = DELETED; + } + static SingletonInstanceData& getData() { // this is static to cache the lookup results diff --git a/indra/llcommon/llversionviewer.h b/indra/llcommon/llversionviewer.h index fa2b3bff36..64225b859b 100755 --- a/indra/llcommon/llversionviewer.h +++ b/indra/llcommon/llversionviewer.h @@ -29,7 +29,7 @@ const S32 LL_VERSION_MAJOR = 3; const S32 LL_VERSION_MINOR = 0; -const S32 LL_VERSION_PATCH = 2; +const S32 LL_VERSION_PATCH = 3; const S32 LL_VERSION_BUILD = 0; const char * const LL_CHANNEL = "Second Life Developer"; diff --git a/indra/llcommon/tests/llinstancetracker_test.cpp b/indra/llcommon/tests/llinstancetracker_test.cpp index 3caf49aa6e..80b35bbdc3 100644 --- a/indra/llcommon/tests/llinstancetracker_test.cpp +++ b/indra/llcommon/tests/llinstancetracker_test.cpp @@ -90,79 +90,79 @@ namespace tut ensure_equals(Keyed::instanceCount(), 0); } - // template<> template<> - // void object::test<2>() - // { - // ensure_equals(Unkeyed::instanceCount(), 0); - // { - // Unkeyed one; - // ensure_equals(Unkeyed::instanceCount(), 1); - // Unkeyed* found = Unkeyed::getInstance(&one); - // ensure_equals(found, &one); - // { - // boost::scoped_ptr<Unkeyed> two(new Unkeyed); - // ensure_equals(Unkeyed::instanceCount(), 2); - // Unkeyed* found = Unkeyed::getInstance(two.get()); - // ensure_equals(found, two.get()); - // } - // ensure_equals(Unkeyed::instanceCount(), 1); - // } - // ensure_equals(Unkeyed::instanceCount(), 0); - // } + template<> template<> + void object::test<2>() + { + ensure_equals(Unkeyed::instanceCount(), 0); + { + Unkeyed one; + ensure_equals(Unkeyed::instanceCount(), 1); + Unkeyed* found = Unkeyed::getInstance(&one); + ensure_equals(found, &one); + { + boost::scoped_ptr<Unkeyed> two(new Unkeyed); + ensure_equals(Unkeyed::instanceCount(), 2); + Unkeyed* found = Unkeyed::getInstance(two.get()); + ensure_equals(found, two.get()); + } + ensure_equals(Unkeyed::instanceCount(), 1); + } + ensure_equals(Unkeyed::instanceCount(), 0); + } - // template<> template<> - // void object::test<3>() - // { - // Keyed one("one"), two("two"), three("three"); - // // We don't want to rely on the underlying container delivering keys - // // in any particular order. That allows us the flexibility to - // // reimplement LLInstanceTracker using, say, a hash map instead of a - // // std::map. We DO insist that every key appear exactly once. - // typedef std::vector<std::string> StringVector; - // StringVector keys(Keyed::beginKeys(), Keyed::endKeys()); - // std::sort(keys.begin(), keys.end()); - // StringVector::const_iterator ki(keys.begin()); - // ensure_equals(*ki++, "one"); - // ensure_equals(*ki++, "three"); - // ensure_equals(*ki++, "two"); - // // Use ensure() here because ensure_equals would want to display - // // mismatched values, and frankly that wouldn't help much. - // ensure("didn't reach end", ki == keys.end()); + template<> template<> + void object::test<3>() + { + Keyed one("one"), two("two"), three("three"); + // We don't want to rely on the underlying container delivering keys + // in any particular order. That allows us the flexibility to + // reimplement LLInstanceTracker using, say, a hash map instead of a + // std::map. We DO insist that every key appear exactly once. + typedef std::vector<std::string> StringVector; + StringVector keys(Keyed::beginKeys(), Keyed::endKeys()); + std::sort(keys.begin(), keys.end()); + StringVector::const_iterator ki(keys.begin()); + ensure_equals(*ki++, "one"); + ensure_equals(*ki++, "three"); + ensure_equals(*ki++, "two"); + // Use ensure() here because ensure_equals would want to display + // mismatched values, and frankly that wouldn't help much. + ensure("didn't reach end", ki == keys.end()); - // // Use a somewhat different approach to order independence with - // // beginInstances(): explicitly capture the instances we know in a - // // set, and delete them as we iterate through. - // typedef std::set<Keyed*> InstanceSet; - // InstanceSet instances; - // instances.insert(&one); - // instances.insert(&two); - // instances.insert(&three); - // for (Keyed::instance_iter ii(Keyed::beginInstances()), iend(Keyed::endInstances()); - // ii != iend; ++ii) - // { - // Keyed& ref = *ii; - // ensure_equals("spurious instance", instances.erase(&ref), 1); - // } - // ensure_equals("unreported instance", instances.size(), 0); - // } + // Use a somewhat different approach to order independence with + // beginInstances(): explicitly capture the instances we know in a + // set, and delete them as we iterate through. + typedef std::set<Keyed*> InstanceSet; + InstanceSet instances; + instances.insert(&one); + instances.insert(&two); + instances.insert(&three); + for (Keyed::instance_iter ii(Keyed::beginInstances()), iend(Keyed::endInstances()); + ii != iend; ++ii) + { + Keyed& ref = *ii; + ensure_equals("spurious instance", instances.erase(&ref), 1); + } + ensure_equals("unreported instance", instances.size(), 0); + } + + template<> template<> + void object::test<4>() + { + Unkeyed one, two, three; + typedef std::set<Unkeyed*> KeySet; + + KeySet instances; + instances.insert(&one); + instances.insert(&two); + instances.insert(&three); - // template<> template<> - // void object::test<4>() - // { - // Unkeyed one, two, three; - // typedef std::set<Unkeyed*> KeySet; - // - // KeySet instances; - // instances.insert(&one); - // instances.insert(&two); - // instances.insert(&three); - - //for (Unkeyed::instance_iter ii(Unkeyed::beginInstances()), iend(Unkeyed::endInstances()); ii != iend; ++ii) - //{ - // Unkeyed& ref = *ii; - // ensure_equals("spurious instance", instances.erase(&ref), 1); - //} - - // ensure_equals("unreported instance", instances.size(), 0); - // } + for (Unkeyed::instance_iter ii(Unkeyed::beginInstances()), iend(Unkeyed::endInstances()); ii != iend; ++ii) + { + Unkeyed& ref = *ii; + ensure_equals("spurious instance", instances.erase(&ref), 1); + } + + ensure_equals("unreported instance", instances.size(), 0); + } } // namespace tut |