nat_linden avatar nat_linden committed de4de42

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.

Comments (0)

Files changed (2)

indra/llui/llui.cpp

 	}
 
 	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

indra/llvfs/lldir.cpp

 #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;
 
 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
 													 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 "
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.