summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2013-08-05 19:43:06 -0400
committerNat Goodspeed <nat@lindenlab.com>2013-08-05 19:43:06 -0400
commit7f6e7fc0cb15d5367d48a3d8084d1a0b319575b7 (patch)
treecb3c577d17607a644ab402afaa0c382379c9fe80 /indra/newview/llappviewer.cpp
parentacda43ed3881eeab60ee9edfdf76ac8eebd723cc (diff)
CHOP-951, IQA-1477: Validate args for numeric command-line switches.
The logic in llcommandlineparser.cpp's setControlValueCB() callback function for converting command-line switch argument values from string to the actual type of the map-to settings variable had a couple special cases for boolean and LLSD array. But for S32, U32 and F32, it simply used default LLSD string-to-numeric conversion. LLSD's string-to-numeric conversion is a bit lame: for non-numeric strings, it shrugs and returns 0. Introduce onevalue() and badvalue() helper functions that, like certain errors during command-line parsing, throw LLCLPError. Use them to streamline certain redundancies in setControlValueCB(). Introduce convertTo<T>() helper function that uses boost::lexical_cast() for slightly more stringent conversions. Add cases for U32, S32 and F32 targets. setControlValueCB() is actually called only by LLControlGroupCLP::notify(), not during actual command-line parsing. Make LLControlGroupCLP::notify() return bool. Make it catch LLCLPError, set the error for getErrorMessage() and return false on that exception. Package LLAppViewer::initConfiguration()'s response to initParseCommandLine() returning false as a new handleCommandLineError() function; invoke it both there and when LLControlGroupCLP::notify() returns false.
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rwxr-xr-xindra/newview/llappviewer.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 6132e9b466..b2aadf9cc0 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2306,6 +2306,20 @@ void LLAppViewer::loadColorSettings()
LLUIColorTable::instance().loadFromSettings();
}
+namespace
+{
+ void handleCommandLineError(LLControlGroupCLP& clp)
+ {
+ llwarns << "Error parsing command line options. Command Line options ignored." << llendl;
+
+ llinfos << "Command line usage:\n" << clp << llendl;
+
+ OSMessageBox(STRINGIZE(LLTrans::getString("MBCmdLineError") << clp.getErrorMessage()),
+ LLStringUtil::null,
+ OSMB_OK);
+ }
+} // anonymous namespace
+
bool LLAppViewer::initConfiguration()
{
//Load settings files list
@@ -2404,13 +2418,7 @@ bool LLAppViewer::initConfiguration()
if(!initParseCommandLine(clp))
{
- llwarns << "Error parsing command line options. Command Line options ignored." << llendl;
-
- llinfos << "Command line usage:\n" << clp << llendl;
-
- std::ostringstream msg;
- msg << LLTrans::getString("MBCmdLineError") << clp.getErrorMessage();
- OSMessageBox(msg.str(),LLStringUtil::null,OSMB_OK);
+ handleCommandLineError(clp);
return false;
}
@@ -2457,7 +2465,11 @@ bool LLAppViewer::initConfiguration()
loadSettingsFromDirectory("UserSession");
// - apply command line settings
- clp.notify();
+ if (! clp.notify())
+ {
+ handleCommandLineError(clp);
+ return false;
+ }
// Register the core crash option as soon as we can
// if we want gdb post-mortem on cores we need to be up and running