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.master
parent
6ca3706808
commit
543b7ee9f7
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 "
|
||||
|
|
|
|||
Loading…
Reference in New Issue