From 436b30c6fcf277c49d525d1bfc72d13f67527499 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 1 Oct 2015 12:25:03 -0700 Subject: [PATCH] Changed option loading mechanism --- src/CmdLineOptParser.cc | 4 +++- src/CmdLineOptParser.h | 2 +- src/main.cc | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/CmdLineOptParser.cc b/src/CmdLineOptParser.cc index ac125d228..e811be6d4 100644 --- a/src/CmdLineOptParser.cc +++ b/src/CmdLineOptParser.cc @@ -51,7 +51,9 @@ void ParseCmdLineOptions(int& argc, ///< count of ar if (arg.startsWith(QString("%1:").arg(optionStr), Qt::CaseInsensitive)) { found = true; - prgOpts[iOption].optionArg = arg.right(arg.length() - (optionStr.length() + 1)); + if (prgOpts[iOption].optionArg) { + *prgOpts[iOption].optionArg = arg.right(arg.length() - (optionStr.length() + 1)); + } } else if (arg.compare(optionStr, Qt::CaseInsensitive) == 0) { found = true; } diff --git a/src/CmdLineOptParser.h b/src/CmdLineOptParser.h index c5a1362ed..c0402d62f 100644 --- a/src/CmdLineOptParser.h +++ b/src/CmdLineOptParser.h @@ -36,7 +36,7 @@ typedef struct { const char* optionStr; ///< command line option, for example "--foo" bool* optionFound; ///< if option is found this variable will be set to true - QString optionArg; ///< Option has additional argument, form is option:arg + QString* optionArg; ///< Option has additional argument, form is option:arg } CmdLineOpt_t; void ParseCmdLineOptions(int& argc, diff --git a/src/main.cc b/src/main.cc index 3a1a4bf58..510078d27 100644 --- a/src/main.cc +++ b/src/main.cc @@ -135,9 +135,10 @@ int main(int argc, char *argv[]) bool quietWindowsAsserts = false; // Don't let asserts pop dialog boxes + QString unitTestOptions; CmdLineOpt_t rgCmdLineOptions[] = { - { "--unittest", &runUnitTests, QString() }, - { "--no-windows-assert-ui", &quietWindowsAsserts, QString() }, + { "--unittest", &runUnitTests, &unitTestOptions }, + { "--no-windows-assert-ui", &quietWindowsAsserts, NULL }, // Add additional command line option flags here }; @@ -181,7 +182,7 @@ int main(int argc, char *argv[]) } // Run the test - int failures = UnitTest::run(rgCmdLineOptions[0].optionArg); + int failures = UnitTest::run(unitTestOptions); if (failures == 0) { qDebug() << "ALL TESTS PASSED"; } else { -- 2.22.0