diff options
| author | Nat Goodspeed <nat@lindenlab.com> | 2012-10-12 11:09:25 -0400 | 
|---|---|---|
| committer | Nat Goodspeed <nat@lindenlab.com> | 2012-10-12 11:09:25 -0400 | 
| commit | 543b7ee9f7eb104497e971961fc0c39ed32ef54d (patch) | |
| tree | e20e152fa434c2d888cd1b6b256a9356618ec268 | |
| parent | 6ca37068080e3b26e5cb163dfd874bc0e2f4c837 (diff) | |
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.
| -rw-r--r-- | indra/llui/llui.cpp | 8 | ||||
| -rw-r--r-- | indra/llvfs/lldir.cpp | 71 | 
2 files changed, 38 insertions, 41 deletions
| diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp index 507ced9172..6d2bc1837c 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1859,15 +1859,13 @@ std::string LLUI::locateSkin(const std::string& filename)  	}  	found_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, filename); -/*==========================================================================*| -	// Hmm, if we got this far, previous implementation of this method would -	// return this last found_file value whether or not it actually exists.  	if (gDirUtilp->fileExists(found_file))  	{  		return found_file;  	} -|*==========================================================================*/ -	return found_file; +	LL_WARNS("LLUI") << "Can't find '" << filename +					 << "' in user settings, any skin directory or app_settings" << LL_ENDL; +	return "";  }  //static 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 <boost/foreach.hpp>  #include <boost/range/begin.hpp>  #include <boost/range/end.hpp> +#include <boost/assign/list_of.hpp>  #include <algorithm> +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<ELLPath, const char*> 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<ELLPath, const char*> 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<std::string> 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<std::string> sUnlocalized(boost::begin(sUnlocalizedData), -													boost::end(sUnlocalizedData)); +	static const std::set<std::string> sUnlocalized = list_of +		("")                        // top-level directory not localized +		("textures")                // textures not localized +	;  	LL_DEBUGS("LLDir") << "subdir '" << subdir << "', filename '" << filename  					   << "', constraint " | 
