@@ -15,7 +15,7 @@ constexpr char GUI_TEST_CLI_OPT[] = "guitest";
1515constexpr char MAX_QT_LOGGING_CLI_OPT[] = " maxlogs" ;
1616constexpr char COLOR_PALETTE_CLI_OPT[] = " colorpalette" ;
1717
18- CliOptions::CliOptions ( const QCoreApplication& app )
18+ CliOptions::CliOptions ( const QCoreApplication& app, bool stopAtParseOnly )
1919{
2020 QCommandLineParser parser;
2121 parser.addHelpOption ();
@@ -27,7 +27,27 @@ CliOptions::CliOptions( const QCoreApplication& app )
2727 { { " c" , COLOR_PALETTE_CLI_OPT }, " show color palette to allow for on-the-fly color experiments" },
2828 } );
2929
30- parser.process ( app );
30+ if ( !stopAtParseOnly )
31+ {
32+ // The NOT-stop case is the full desktop application.
33+ // This call to 'process' gives us parsing and type-checking and error
34+ // reporting. (In other words, everything you would want in a full app.)
35+ parser.process ( app );
36+ }
37+ else
38+ {
39+ // The 'stopAtParseOnly' case is the case when this instance of
40+ // CliOptions is part of our 'lightly hacked' and 'project aware'
41+ // locally-built qmlscene.
42+ // We MUST NOT CALL QCommandLineParser::process IN THIS CASE, because
43+ // it will prevent us from using the arguments that qmlscene accepts in
44+ // its own 'main' function.
45+ // By calling 'parse' instead, we DO achieve the desired capture of
46+ // our app-specific options. As a trade-off, we forgo the built-in
47+ // type-checking and error reporting of QCommandLineParser::process
48+ const QStringList arguments = QCoreApplication::arguments ();
49+ parser.parse ( arguments );
50+ }
3151
3252 m_guiTests = parser.isSet ( GUI_TEST_CLI_OPT );
3353 m_maximumQtLogs = parser.isSet ( MAX_QT_LOGGING_CLI_OPT );
0 commit comments