From 543b7ee9f7eb104497e971961fc0c39ed32ef54d Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 12 Oct 2012 11:09:25 -0400 Subject: Fix LLUI::locateSkin() failure case; clarify lldir.cpp static init. Per code review: Previous refactoring of LLUI::locateSkin() preserved odd failure behavior: it would return last-considered pathname, whether or not it exists. Changed to emit LL_WARNS log message and return empty string. Use Boost.Assign to simplify initialization of a couple static containers in lldir.cpp. --- indra/llvfs/lldir.cpp | 71 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'indra/llvfs') diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index 2d0adf14e6..4c0978b39e 100644 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -45,8 +45,12 @@ #include #include #include +#include #include +using boost::assign::list_of; +using boost::assign::map_list_of; + #if LL_WINDOWS #include "lldir_win32.h" LLDir_Win32 gDirUtil; @@ -342,37 +346,35 @@ const std::string &LLDir::getLLPluginDir() const static std::string ELLPathToString(ELLPath location) { - typedef std::map ELLPathMap; -#define ENT(symbol) ELLPathMap::value_type(symbol, #symbol) - static ELLPathMap::value_type init[] = - { - ENT(LL_PATH_NONE), - ENT(LL_PATH_USER_SETTINGS), - ENT(LL_PATH_APP_SETTINGS), - ENT(LL_PATH_PER_SL_ACCOUNT), // returns/expands to blank string if we don't know the account name yet - ENT(LL_PATH_CACHE), - ENT(LL_PATH_CHARACTER), - ENT(LL_PATH_HELP), - ENT(LL_PATH_LOGS), - ENT(LL_PATH_TEMP), - ENT(LL_PATH_SKINS), - ENT(LL_PATH_TOP_SKIN), - ENT(LL_PATH_CHAT_LOGS), - ENT(LL_PATH_PER_ACCOUNT_CHAT_LOGS), - ENT(LL_PATH_USER_SKIN), - ENT(LL_PATH_LOCAL_ASSETS), - ENT(LL_PATH_EXECUTABLE), - ENT(LL_PATH_DEFAULT_SKIN), - ENT(LL_PATH_FONTS), - ENT(LL_PATH_LAST) - }; + typedef std::map ELLPathMap; +#define ENT(symbol) (symbol, #symbol) + static const ELLPathMap sMap = map_list_of + ENT(LL_PATH_NONE) + ENT(LL_PATH_USER_SETTINGS) + ENT(LL_PATH_APP_SETTINGS) + ENT(LL_PATH_PER_SL_ACCOUNT) // returns/expands to blank string if we don't know the account name yet + ENT(LL_PATH_CACHE) + ENT(LL_PATH_CHARACTER) + ENT(LL_PATH_HELP) + ENT(LL_PATH_LOGS) + ENT(LL_PATH_TEMP) + ENT(LL_PATH_SKINS) + ENT(LL_PATH_TOP_SKIN) + ENT(LL_PATH_CHAT_LOGS) + ENT(LL_PATH_PER_ACCOUNT_CHAT_LOGS) + ENT(LL_PATH_USER_SKIN) + ENT(LL_PATH_LOCAL_ASSETS) + ENT(LL_PATH_EXECUTABLE) + ENT(LL_PATH_DEFAULT_SKIN) + ENT(LL_PATH_FONTS) + ENT(LL_PATH_LAST) + ; #undef ENT - static const ELLPathMap sMap(boost::begin(init), boost::end(init)); - ELLPathMap::const_iterator found = sMap.find(location); - if (found != sMap.end()) - return found->second; - return STRINGIZE("Invalid ELLPath value " << location); + ELLPathMap::const_iterator found = sMap.find(location); + if (found != sMap.end()) + return found->second; + return STRINGIZE("Invalid ELLPath value " << location); } std::string LLDir::getExpandedFilename(ELLPath location, const std::string& filename) const @@ -572,13 +574,10 @@ std::vector LLDir::findSkinnedFilenames(const std::string& subdir, ESkinConstraint constraint) const { // Recognize subdirs that have no localization. - static const char* sUnlocalizedData[] = - { - "", // top-level directory not localized - "textures" // textures not localized - }; - static const std::set sUnlocalized(boost::begin(sUnlocalizedData), - boost::end(sUnlocalizedData)); + static const std::set sUnlocalized = list_of + ("") // top-level directory not localized + ("textures") // textures not localized + ; LL_DEBUGS("LLDir") << "subdir '" << subdir << "', filename '" << filename << "', constraint " -- cgit v1.2.3