From b044e1b82f471ad4bcec798e13968f2b793d81a9 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 25 Oct 2021 16:31:27 -0700 Subject: [PATCH 01/23] Consolidated (almost) all parameters in "main.cpp". --- interface/src/main.cpp | 105 ++++++++++++++++++++++++++++------------- 1 file changed, 71 insertions(+), 34 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 8c8a4c3ce99..bf9f116ce0e 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -64,60 +64,80 @@ int main(int argc, const char* argv[]) { setupHifiApplication(BuildInfo::INTERFACE_NAME); - QStringList arguments; + /*QStringList arguments; for (int i = 0; i < argc; ++i) { arguments << argv[i]; - } + }*/ + + // grep -E 'getCmdOption|QCommandLineOption|cmdOptionExists' 'interface/src/Application.cpp' QCommandLineParser parser; parser.setApplicationDescription("Overte"); - QCommandLineOption versionOption = parser.addVersionOption(); QCommandLineOption helpOption = parser.addHelpOption(); + QCommandLineOption versionOption = parser.addVersionOption(); - QCommandLineOption urlOption("url", "", "value"); - QCommandLineOption noLauncherOption("no-launcher", "Do not execute the launcher"); - QCommandLineOption noUpdaterOption("no-updater", "Do not show auto-updater"); - QCommandLineOption checkMinSpecOption("checkMinSpec", "Check if machine meets minimum specifications"); - QCommandLineOption runServerOption("runServer", "Whether to run the server"); - QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content ", "serverContentPath"); - QCommandLineOption allowMultipleInstancesOption("allowMultipleInstances", "Allow multiple instances to run"); - QCommandLineOption overrideAppLocalDataPathOption("cache", "set test cache ", "dir"); + QCommandLineOption urlOption("url", "Start at specified URL location.", "value"); + QCommandLineOption protocolVersionOption("protocolVersion", "Displays the protocol version."); + QCommandLineOption noUpdaterOption("no-updater", "Do not show auto-updater."); + QCommandLineOption checkMinSpecOption("checkMinSpec", "Check if machine meets minimum specifications."); + QCommandLineOption runServerOption("runServer", "Whether to run the server."); + QCommandLineOption listenPortOption("listenPort", "Port to listen on."); + QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content .", "serverContentPath"); // This data type will not be familiar to users. + QCommandLineOption overrideAppLocalDataPathOption("cache", "set test cache .", "dir"); + //QCommandLineOption scriptsOption("scripts", "Set path for defaultScripts.", "dir"); // Use this once SCRIPTS_SWITCH is removed. + QCommandLineOption allowMultipleInstancesOption("allowMultipleInstances", "Allow multiple instances to run."); + QCommandLineOption displaysOption("display", "Preferred display.", "displays"); + QCommandLineOption disableDisplaysOption("disable-displays", "Displays to disable."); + QCommandLineOption disableInputsOption("disable-inputs", "Inputs to disable."); + QCommandLineOption suppressSettingsResetOption("suppress-settings-reset", "Suppress the prompt to reset interface settings."); + QCommandLineOption oculusStoreOption("oculus-store", "Let the Oculus plugin know if interface was run from the Oculus Store."); + QCommandLineOption standaloneOption("standalone", "Emulate a standalone device."); + QCommandLineOption disableWatchdogOption("disableWatchdog", "Disable the watchdog thread. The interface will crash on deadlocks."); + QCommandLineOption systemCursorOption("system-cursor", "Needs clarification!"); + QCommandLineOption concurrentDownloadsOption("concurrent-downloads", "Maximum concurrent resource downloads. Default is 16, except for Android where it is 4."); + QCommandLineOption avatarURLOption("avatarURL", "Override the avatar U.R.L."); + QCommandLineOption replaceAvatarURLOption("replace-avatar-url", "Replaces the avatar U.R.L. When used with --avatarURL, this takes precedence."); + QCommandLineOption setBookmarkOption("setBookmark", "Set bookmark as key=value pair. Including the '=' symbol in either string is unsupported.", "string"); + QCommandLineOption forceCrashReportingOption("forceCrashReporting", "Force crash reporting to initialize."); + // The documented "--disable-lod" does not seem to exist. + // Below are undocumented. + QCommandLineOption noLauncherOption("no-launcher", "Do not execute the launcher."); QCommandLineOption overrideScriptsPathOption(SCRIPTS_SWITCH, "set scripts ", "path"); - QCommandLineOption responseTokensOption("tokens", "set response tokens ", "json"); - QCommandLineOption displayNameOption("displayName", "set user display name ", "string"); - QCommandLineOption setBookmarkOption("setBookmark", "set bookmark key=value pair", "string"); - QCommandLineOption defaultScriptOverrideOption("defaultScriptsOverride", "override defaultsScripts.js", "string"); - QCommandLineOption forceCrashReportingOption("forceCrashReporting", "Force crash reporting to initialize"); + QCommandLineOption responseTokensOption("tokens", "set response tokens .", "json"); + QCommandLineOption displayNameOption("displayName", "set user display name .", "string"); + QCommandLineOption defaultScriptOverrideOption("defaultScriptsOverride", "override defaultsScripts.js.", "string"); + // "--qmljsdebugger", which appears in output from "--help-all". parser.addOption(urlOption); - parser.addOption(noLauncherOption); + parser.addOption(protocolVersionOption); parser.addOption(noUpdaterOption); parser.addOption(checkMinSpecOption); parser.addOption(runServerOption); + parser.addOption(listenPortOption); parser.addOption(serverContentPathOption); parser.addOption(overrideAppLocalDataPathOption); - parser.addOption(overrideScriptsPathOption); + //parser.addOption(scriptsOption); // Use this once SCRIPTS_SWITCH is removed. parser.addOption(allowMultipleInstancesOption); + parser.addOption(displaysOption); + parser.addOption(disableDisplaysOption); + parser.addOption(disableInputsOption); + parser.addOption(suppressSettingsResetOption); + parser.addOption(oculusStoreOption); + parser.addOption(standaloneOption); + parser.addOption(disableWatchdogOption); + parser.addOption(systemCursorOption); + parser.addOption(concurrentDownloadsOption); + parser.addOption(avatarURLOption); + parser.addOption(replaceAvatarURLOption); + parser.addOption(setBookmarkOption); + parser.addOption(forceCrashReportingOption); + parser.addOption(noLauncherOption); + parser.addOption(overrideScriptsPathOption); // Remove this along with SCRIPTS_SWITCH. parser.addOption(responseTokensOption); parser.addOption(displayNameOption); - parser.addOption(setBookmarkOption); parser.addOption(defaultScriptOverrideOption); - parser.addOption(forceCrashReportingOption); - - if (!parser.parse(arguments)) { - std::cout << parser.errorText().toStdString() << std::endl; // Avoid Qt log spam - } - - if (parser.isSet(versionOption)) { - parser.showVersion(); - Q_UNREACHABLE(); - } - if (parser.isSet(helpOption)) { - QCoreApplication mockApp(argc, const_cast(argv)); // required for call to showHelp() - parser.showHelp(); - Q_UNREACHABLE(); - } + QStringList arguments; QString applicationPath; // A temporary application instance is needed to get the location of the running executable // Tests using high_resolution_clock show that this takes about 30-50 microseconds (on my machine, YMMV) @@ -125,6 +145,10 @@ int main(int argc, const char* argv[]) { // cross-platform implementation. { QCoreApplication tempApp(argc, const_cast(argv)); + + parser.process(QCoreApplication::arguments()); // Must be run after QCoreApplication is initalised. + arguments = parser.positionalArguments(); // Must be run after parser processes arguments. + #ifdef Q_OS_OSX if (QFileInfo::exists(QCoreApplication::applicationDirPath() + "/../../../config.json")) { applicationPath = QCoreApplication::applicationDirPath() + "/../../../"; @@ -135,6 +159,18 @@ int main(int argc, const char* argv[]) { applicationPath = QCoreApplication::applicationDirPath(); #endif } + + // Act on arguments for early termination. + if (parser.isSet(versionOption)) { + parser.showVersion(); + Q_UNREACHABLE(); + } + if (parser.isSet(helpOption)) { + QCoreApplication mockApp(argc, const_cast(argv)); // required for call to showHelp() + parser.showHelp(); + Q_UNREACHABLE(); + } + static const QString APPLICATION_CONFIG_FILENAME = "config.json"; QDir applicationDir(applicationPath); QString configFileName = applicationDir.filePath(APPLICATION_CONFIG_FILENAME); @@ -328,6 +364,7 @@ int main(int argc, const char* argv[]) { // Oculus initialization MUST PRECEDE OpenGL context creation. // The nature of the Application constructor means this has to be either here, // or in the main window ctor, before GL startup. + //Application::initPlugins(arguments); Application::initPlugins(arguments); #ifdef Q_OS_WIN From 09b288d63c629cae55ae6df81d6e4df2262fd522 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 25 Oct 2021 17:33:22 -0700 Subject: [PATCH 02/23] Made lines shorter. --- interface/src/main.cpp | 150 +++++++++++++++++++++++++++++++++-------- 1 file changed, 122 insertions(+), 28 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index bf9f116ce0e..5bcb9c8b8e8 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -76,36 +76,130 @@ int main(int argc, const char* argv[]) { QCommandLineOption helpOption = parser.addHelpOption(); QCommandLineOption versionOption = parser.addVersionOption(); - QCommandLineOption urlOption("url", "Start at specified URL location.", "value"); - QCommandLineOption protocolVersionOption("protocolVersion", "Displays the protocol version."); - QCommandLineOption noUpdaterOption("no-updater", "Do not show auto-updater."); - QCommandLineOption checkMinSpecOption("checkMinSpec", "Check if machine meets minimum specifications."); - QCommandLineOption runServerOption("runServer", "Whether to run the server."); - QCommandLineOption listenPortOption("listenPort", "Port to listen on."); - QCommandLineOption serverContentPathOption("serverContentPath", "Where to find server content .", "serverContentPath"); // This data type will not be familiar to users. - QCommandLineOption overrideAppLocalDataPathOption("cache", "set test cache .", "dir"); - //QCommandLineOption scriptsOption("scripts", "Set path for defaultScripts.", "dir"); // Use this once SCRIPTS_SWITCH is removed. - QCommandLineOption allowMultipleInstancesOption("allowMultipleInstances", "Allow multiple instances to run."); - QCommandLineOption displaysOption("display", "Preferred display.", "displays"); - QCommandLineOption disableDisplaysOption("disable-displays", "Displays to disable."); - QCommandLineOption disableInputsOption("disable-inputs", "Inputs to disable."); - QCommandLineOption suppressSettingsResetOption("suppress-settings-reset", "Suppress the prompt to reset interface settings."); - QCommandLineOption oculusStoreOption("oculus-store", "Let the Oculus plugin know if interface was run from the Oculus Store."); - QCommandLineOption standaloneOption("standalone", "Emulate a standalone device."); - QCommandLineOption disableWatchdogOption("disableWatchdog", "Disable the watchdog thread. The interface will crash on deadlocks."); - QCommandLineOption systemCursorOption("system-cursor", "Needs clarification!"); - QCommandLineOption concurrentDownloadsOption("concurrent-downloads", "Maximum concurrent resource downloads. Default is 16, except for Android where it is 4."); - QCommandLineOption avatarURLOption("avatarURL", "Override the avatar U.R.L."); - QCommandLineOption replaceAvatarURLOption("replace-avatar-url", "Replaces the avatar U.R.L. When used with --avatarURL, this takes precedence."); - QCommandLineOption setBookmarkOption("setBookmark", "Set bookmark as key=value pair. Including the '=' symbol in either string is unsupported.", "string"); - QCommandLineOption forceCrashReportingOption("forceCrashReporting", "Force crash reporting to initialize."); + QCommandLineOption urlOption( + "url", + "Start at specified URL location.", + "value" + ); + QCommandLineOption protocolVersionOption( + "protocolVersion", + "Displays the protocol version." + ); + QCommandLineOption noUpdaterOption( + "no-updater", + "Do not show auto-updater." + ); + QCommandLineOption checkMinSpecOption( + "checkMinSpec", + "Check if machine meets minimum specifications." + ); + QCommandLineOption runServerOption( + "runServer", + "Whether to run the server." + ); + QCommandLineOption listenPortOption( + "listenPort", + "Port to listen on." + ); + QCommandLineOption serverContentPathOption( + "serverContentPath", + "Where to find server content .", + "serverContentPath" + ); // This data type will not be familiar to users. + QCommandLineOption overrideAppLocalDataPathOption( + "cache", + "set test cache .", + "dir" + ); + //QCommandLineOption scriptsOption( + // "scripts", + // "Set path for defaultScripts.", + // "dir" + //); // Use this once SCRIPTS_SWITCH is removed. + QCommandLineOption allowMultipleInstancesOption( + "allowMultipleInstances", + "Allow multiple instances to run." + ); + QCommandLineOption displaysOption( + "display", + "Preferred display.", + "displays" + ); + QCommandLineOption disableDisplaysOption( + "disable-displays", + "Displays to disable." + ); + QCommandLineOption disableInputsOption( + "disable-inputs", + "Inputs to disable." + ); + QCommandLineOption suppressSettingsResetOption( + "suppress-settings-reset", + "Suppress the prompt to reset interface settings." + ); + QCommandLineOption oculusStoreOption( + "oculus-store", + "Let the Oculus plugin know if interface was run from the Oculus Store." + ); + QCommandLineOption standaloneOption( + "standalone", + "Emulate a standalone device." + ); + QCommandLineOption disableWatchdogOption( + "disableWatchdog", + "Disable the watchdog thread. The interface will crash on deadlocks." + ); + QCommandLineOption systemCursorOption( + "system-cursor", + "Needs clarification!" + ); + QCommandLineOption concurrentDownloadsOption( + "concurrent-downloads", + "Maximum concurrent resource downloads. Default is 16, except for Android where it is 4." + ); + QCommandLineOption avatarURLOption( + "avatarURL", + "Override the avatar U.R.L." + ); + QCommandLineOption replaceAvatarURLOption( + "replace-avatar-url", + "Replaces the avatar U.R.L. When used with --avatarURL, this takes precedence." + ); + QCommandLineOption setBookmarkOption( + "setBookmark", + "Set bookmark as key=value pair. Including the '=' symbol in either string is unsupported.", + "string" + ); + QCommandLineOption forceCrashReportingOption( + "forceCrashReporting", + "Force crash reporting to initialize." + ); // The documented "--disable-lod" does not seem to exist. // Below are undocumented. - QCommandLineOption noLauncherOption("no-launcher", "Do not execute the launcher."); - QCommandLineOption overrideScriptsPathOption(SCRIPTS_SWITCH, "set scripts ", "path"); - QCommandLineOption responseTokensOption("tokens", "set response tokens .", "json"); - QCommandLineOption displayNameOption("displayName", "set user display name .", "string"); - QCommandLineOption defaultScriptOverrideOption("defaultScriptsOverride", "override defaultsScripts.js.", "string"); + QCommandLineOption noLauncherOption( + "no-launcher", + "Do not execute the launcher." + ); + QCommandLineOption overrideScriptsPathOption( + SCRIPTS_SWITCH, + "set scripts ", + "path" + ); + QCommandLineOption responseTokensOption( + "tokens", + "set response tokens .", + "json" + ); + QCommandLineOption displayNameOption( + "displayName", + "set user display name .", + "string" + ); + QCommandLineOption defaultScriptOverrideOption( + "defaultScriptsOverride", + "override defaultsScripts.js.", + "string" + ); // "--qmljsdebugger", which appears in output from "--help-all". parser.addOption(urlOption); From f0247cba24ceb715e8de0ca7d9f2e7a1612390f2 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 25 Oct 2021 17:36:14 -0700 Subject: [PATCH 03/23] Removed unnecessary comments. --- interface/src/main.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 5bcb9c8b8e8..89ee0c7b277 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -64,11 +64,6 @@ int main(int argc, const char* argv[]) { setupHifiApplication(BuildInfo::INTERFACE_NAME); - /*QStringList arguments; - for (int i = 0; i < argc; ++i) { - arguments << argv[i]; - }*/ - // grep -E 'getCmdOption|QCommandLineOption|cmdOptionExists' 'interface/src/Application.cpp' QCommandLineParser parser; @@ -458,7 +453,6 @@ int main(int argc, const char* argv[]) { // Oculus initialization MUST PRECEDE OpenGL context creation. // The nature of the Application constructor means this has to be either here, // or in the main window ctor, before GL startup. - //Application::initPlugins(arguments); Application::initPlugins(arguments); #ifdef Q_OS_WIN From 15c346423ff7ce495d6aa42eeb74a61315999618 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 25 Oct 2021 18:32:14 -0700 Subject: [PATCH 04/23] Added note of other parameters to fix. --- interface/src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 89ee0c7b277..30b0c57b4ff 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -196,6 +196,11 @@ int main(int argc, const char* argv[]) { "string" ); // "--qmljsdebugger", which appears in output from "--help-all". + // Those below are found in this file but have not yet been moved here. + // --traceFile + // --clockSkew + // --ignore-gpu-blacklist + // --suppress-settings-reset parser.addOption(urlOption); parser.addOption(protocolVersionOption); From 197b78d228f776e66c2cd9dcece234d970cd421f Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 25 Oct 2021 22:32:47 -0700 Subject: [PATCH 05/23] Probably finished the ones in main. --- interface/src/main.cpp | 58 +++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 30b0c57b4ff..1151d031874 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -177,28 +177,40 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption overrideScriptsPathOption( SCRIPTS_SWITCH, - "set scripts ", + "Set scripts ", "path" ); + QCommandLineOption defaultScriptOverrideOption( + "defaultScriptsOverride", + "Override defaultsScripts.js.", + "string" + ); QCommandLineOption responseTokensOption( "tokens", - "set response tokens .", + "Set response tokens .", "json" ); QCommandLineOption displayNameOption( "displayName", - "set user display name .", + "Set user display name .", "string" ); - QCommandLineOption defaultScriptOverrideOption( - "defaultScriptsOverride", - "override defaultsScripts.js.", - "string" + QCommandLineOption traceFileOption( + "traceFile", + "Probably writes a trace to a file?", + "path" + ); + QCommandLineOption traceDurationOption( + "traceDuration", + "Only works if \"--traceFile\" is provided.", + "value" + ); + QCommandLineOption clockSkewOption( + "clockSkew", + "Forces client instance's clock to skew for demonstration purposes." ); // "--qmljsdebugger", which appears in output from "--help-all". - // Those below are found in this file but have not yet been moved here. - // --traceFile - // --clockSkew + // Those below don't seem to be optional. // --ignore-gpu-blacklist // --suppress-settings-reset @@ -230,6 +242,9 @@ int main(int argc, const char* argv[]) { parser.addOption(responseTokensOption); parser.addOption(displayNameOption); parser.addOption(defaultScriptOverrideOption); + parser.addOption(traceFileOption); + parser.addOption(traceDurationOption); + parser.addOption(clockSkewOption); QStringList arguments; QString applicationPath; @@ -303,18 +318,14 @@ int main(int argc, const char* argv[]) { // Early check for --traceFile argument auto tracer = DependencyManager::set(); const char * traceFile = nullptr; - const QString traceFileFlag("--traceFile"); - float traceDuration = 0.0f; - for (int a = 1; a < argc; ++a) { - if (traceFileFlag == argv[a] && argc > a + 1) { - traceFile = argv[a + 1]; - if (argc > a + 2) { - traceDuration = atof(argv[a + 2]); - } - break; + float traceDuration; + if (parser.isSet(traceFileOption)) { + traceFile = parser.value(traceFileOption).toStdString().c_str(); + if (parser.isSet(traceDurationOption)) { + traceDuration = parser.value(traceDurationOption).toFloat(); + } else { + traceDuration = 0.0f; } - } - if (traceFile != nullptr) { tracer->startTracing(); } @@ -447,9 +458,8 @@ int main(int argc, const char* argv[]) { // Debug option to demonstrate that the client's local time does not // need to be in sync with any other network node. This forces clock // skew for the individual client - const char* CLOCK_SKEW = "--clockSkew"; - const char* clockSkewOption = getCmdOption(argc, argv, CLOCK_SKEW); - if (clockSkewOption) { + if (parser.isSet(clockSkewOption)) { + const char* clockSkewOption = parser.value(clockSkewOption).toStdString().c_str(); qint64 clockSkew = atoll(clockSkewOption); usecTimestampNowForceClockSkew(clockSkew); qCDebug(interfaceapp) << "clockSkewOption=" << clockSkewOption << "clockSkew=" << clockSkew; From a3ac63443e6c708139436c160d67b38d6b119599 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Mon, 25 Oct 2021 22:37:13 -0700 Subject: [PATCH 06/23] Fixed spacing. --- interface/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 1151d031874..b9657603ef5 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -321,7 +321,7 @@ int main(int argc, const char* argv[]) { float traceDuration; if (parser.isSet(traceFileOption)) { traceFile = parser.value(traceFileOption).toStdString().c_str(); - if (parser.isSet(traceDurationOption)) { + if (parser.isSet(traceDurationOption)) { traceDuration = parser.value(traceDurationOption).toFloat(); } else { traceDuration = 0.0f; From 3cbce8e51b7398764fe6335dc3174d505e972bb1 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 26 Oct 2021 06:11:51 -0700 Subject: [PATCH 07/23] Suppose effect. --- interface/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index b9657603ef5..252632c23f4 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -146,7 +146,7 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption systemCursorOption( "system-cursor", - "Needs clarification!" + "Probably prevents changing the cursor when application has focus." ); QCommandLineOption concurrentDownloadsOption( "concurrent-downloads", From dd75c14dbad61d5dec170ab26493200e88337479 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 26 Oct 2021 07:13:59 -0700 Subject: [PATCH 08/23] Fixed handling of clockSkew parameter. --- interface/src/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 252632c23f4..e30aa70f227 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -207,7 +207,8 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption clockSkewOption( "clockSkew", - "Forces client instance's clock to skew for demonstration purposes." + "Forces client instance's clock to skew for demonstration purposes.", + "value" ); // "--qmljsdebugger", which appears in output from "--help-all". // Those below don't seem to be optional. @@ -459,10 +460,10 @@ int main(int argc, const char* argv[]) { // need to be in sync with any other network node. This forces clock // skew for the individual client if (parser.isSet(clockSkewOption)) { - const char* clockSkewOption = parser.value(clockSkewOption).toStdString().c_str(); - qint64 clockSkew = atoll(clockSkewOption); + const char* clockSkewValue = parser.value(clockSkewOption).toStdString().c_str(); + qint64 clockSkew = atoll(clockSkewValue); usecTimestampNowForceClockSkew(clockSkew); - qCDebug(interfaceapp) << "clockSkewOption=" << clockSkewOption << "clockSkew=" << clockSkew; + qCDebug(interfaceapp) << "clockSkewOption=" << clockSkewValue << "clockSkew=" << clockSkew; } // Oculus initialization MUST PRECEDE OpenGL context creation. From e1d79c7b598eecc20e59336368fcc0c21e444512 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 26 Oct 2021 11:58:54 -0700 Subject: [PATCH 09/23] Streamlined handling with single parameter source. --- interface/src/Application.cpp | 203 +++++++++++++++------------------- interface/src/Application.h | 19 +++- interface/src/main.cpp | 63 ++++++++--- 3 files changed, 149 insertions(+), 136 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 0bf9d126da5..5484d2b838d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -724,12 +723,9 @@ extern DisplayPluginList getDisplayPlugins(); extern InputPluginList getInputPlugins(); extern void saveInputPluginSettings(const InputPluginList& plugins); -// Parameters used for running tests from teh command line -const QString TEST_SCRIPT_COMMAND{ "--testScript" }; -const QString TEST_QUIT_WHEN_FINISHED_OPTION{ "quitWhenFinished" }; -const QString TEST_RESULTS_LOCATION_COMMAND{ "--testResultsLocation" }; +// Parameters used for running tests from the command line -bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { +bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, bool runningMarkerExisted) { const char** constArgv = const_cast(argv); qInstallMessageHandler(messageHandler); @@ -737,6 +733,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { // HRS: I could not figure out how to move these any earlier in startup, so when using this option, be sure to also supply // --allowMultipleInstances auto reportAndQuit = [&](const char* commandSwitch, std::function report) { + // Do something about this: const char* reportfile = getCmdOption(argc, constArgv, commandSwitch); // Reports to the specified file, because stdout is set up to be captured for logging. if (reportfile) { @@ -755,36 +752,23 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { reportAndQuit("--protocolVersion", [&](FILE* fp) { auto version = protocolVersionsSignatureBase64(); fputs(version.toLatin1().data(), fp); - }); - reportAndQuit("--version", [&](FILE* fp) { + }); // This doesn't seem to work. + /*reportAndQuit("--version", [&](FILE* fp) { fputs(BuildInfo::VERSION.toLatin1().data(), fp); - }); + });*/ - const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); - const int listenPort = portStr ? atoi(portStr) : INVALID_PORT; + const int listenPort = parser->isSet("listenPort") ? parser->value("listenPort").toInt() : INVALID_PORT; - static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset"; - bool suppressPrompt = cmdOptionExists(argc, const_cast(argv), SUPPRESS_SETTINGS_RESET); + bool suppressPrompt = parser->isSet("suppress-settings-reset"); // set the OCULUS_STORE property so the oculus plugin can know if we ran from the Oculus Store - static const auto OCULUS_STORE_ARG = "--oculus-store"; - bool isStore = cmdOptionExists(argc, const_cast(argv), OCULUS_STORE_ARG); - qApp->setProperty(hifi::properties::OCULUS_STORE, isStore); + qApp->setProperty(hifi::properties::OCULUS_STORE, parser->isSet("oculus-store")); // emulate standalone device - static const auto STANDALONE_ARG = "--standalone"; - bool isStandalone = cmdOptionExists(argc, const_cast(argv), STANDALONE_ARG); - qApp->setProperty(hifi::properties::STANDALONE, isStandalone); + qApp->setProperty(hifi::properties::STANDALONE, parser->isSet("standalone")); // Ignore any previous crashes if running from command line with a test script. - bool inTestMode { false }; - for (int i = 0; i < argc; ++i) { - QString parameter(argv[i]); - if (parameter == TEST_SCRIPT_COMMAND) { - inTestMode = true; - break; - } - } + bool inTestMode = parser->isSet("testScript"); bool previousSessionCrashed { false }; if (!inTestMode) { @@ -792,10 +776,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { } // get dir to use for cache - static const auto CACHE_SWITCH = "--cache"; - QString cacheDir = getCmdOption(argc, const_cast(argv), CACHE_SWITCH); - if (!cacheDir.isEmpty()) { - qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir); + if (parser->isSet("cache")) { + qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, parser->value("cache")); } { @@ -837,7 +819,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { QCoreApplication::addLibraryPath(audioDLLPath); #endif - QString defaultScriptsOverrideOption = getCmdOption(argc, constArgv, "--defaultScriptsOverride"); + QString defaultScriptsOverrideOption = parser->value("defaultScriptsOverride"); DependencyManager::registerInheritance(); DependencyManager::registerInheritance(); @@ -963,7 +945,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { }); - QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark"); + QString setBookmarkValue = parser->value("setBookmark"); if (!setBookmarkValue.isEmpty()) { // Bookmarks are expected to be in a name=url form. // An `=` character in the name or url is unsupported. @@ -1020,14 +1002,19 @@ QSharedPointer getOffscreenUI() { #endif } -Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) : +Application::Application( + int& argc, char** argv, + const QCommandLineParser* parser, + QElapsedTimer& startupTimer, + bool runningMarkerExisted +) : QApplication(argc, argv), _window(new MainWindow(desktop())), _sessionRunTimer(startupTimer), #ifndef Q_OS_ANDROID _logger(new FileLogger(this)), #endif - _previousSessionCrashed(setupEssentials(argc, argv, runningMarkerExisted)), + _previousSessionCrashed(setupEssentials(argc, argv, parser, runningMarkerExisted)), _entitySimulation(std::make_shared()), _physicsEngine(std::make_shared(Vectors::ZERO)), _entityClipboard(std::make_shared()), @@ -1064,12 +1051,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo LogHandler::getInstance().setupRepeatedMessageFlusher(); { - const QStringList args = arguments(); - - for (int i = 0; i < args.size() - 1; ++i) { - if (args.at(i) == TEST_SCRIPT_COMMAND && (i + 1) < args.size()) { - QString testScriptPath = args.at(i + 1); - + if (parser->isSet("testScript")) { + QString testScriptPath = parser->value("testScript"); // If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file // This is done so as not break previous command line scripts if (testScriptPath.left(HIFI_URL_SCHEME_HTTP.length()) == HIFI_URL_SCHEME_HTTP || @@ -1080,20 +1063,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); } - // quite when finished parameter must directly follow the test script - if ((i + 2) < args.size() && args.at(i + 2) == TEST_QUIT_WHEN_FINISHED_OPTION) { + if (parser->isSet("quitWhenFinished")) { quitWhenFinished = true; } - } else if (args.at(i) == TEST_RESULTS_LOCATION_COMMAND) { - // Set test snapshot location only if it is a writeable directory - QString path(args.at(i + 1)); + } + if (parser->isSet("testResultsLocation")) { + // Set test snapshot location only if it is a writeable directory + QString path = parser->value("testResultsLocation"); - QFileInfo fileInfo(path); - if (fileInfo.isDir() && fileInfo.isWritable()) { - TestScriptingInterface::getInstance()->setTestResultsLocation(path); - } + QFileInfo fileInfo(path); + if (fileInfo.isDir() && fileInfo.isWritable()) { + TestScriptingInterface::getInstance()->setTestResultsLocation(path); } } + _urlParam = parser->value("url"); } { @@ -1159,8 +1142,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo auto addressManager = DependencyManager::get(); addressManager->moveToThread(nodeList->thread()); - const char** constArgv = const_cast(argv); - if (cmdOptionExists(argc, constArgv, "--disableWatchdog")) { + if (parser->isSet("disableWatchdog")) { DISABLE_WATCHDOG = true; } // Set up a watchdog thread to intentionally crash the application on deadlocks @@ -1481,24 +1463,26 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent); connect(&_entityEditSender, &EntityEditPacketSender::addingEntityWithCertificate, this, &Application::addingEntityWithCertificate); - QString concurrentDownloadsStr = getCmdOption(argc, constArgv, "--concurrent-downloads"); - bool success; - uint32_t concurrentDownloads = concurrentDownloadsStr.toUInt(&success); - if (!success) { - concurrentDownloads = MAX_CONCURRENT_RESOURCE_DOWNLOADS; + if (parser->isSet("concurrent-downloads")) { + bool success; + uint32_t concurrentDownloads = parser->value("concurrent-downloads").toUInt(&success); + if (!success) { + concurrentDownloads = MAX_CONCURRENT_RESOURCE_DOWNLOADS; + } + ResourceCache::setRequestLimit(concurrentDownloads); } - ResourceCache::setRequestLimit(concurrentDownloads); // perhaps override the avatar url. Since we will test later for validity // we don't need to do so here. - QString avatarURL = getCmdOption(argc, constArgv, "--avatarURL"); - _avatarOverrideUrl = QUrl::fromUserInput(avatarURL); + if (parser->isSet("avatarURL")) { + _avatarOverrideUrl = QUrl::fromUserInput(parser->value("avatarURL")); + } // If someone specifies both --avatarURL and --replaceAvatarURL, // the replaceAvatarURL wins. So only set the _overrideUrl if this // does have a non-empty string. - QString replaceURL = getCmdOption(argc, constArgv, "--replaceAvatarURL"); - if (!replaceURL.isEmpty()) { + if (parser->isSet("replaceAvatarURL")) { + QString replaceURL = parser->value("replaceAvatarURL"); _avatarOverrideUrl = QUrl::fromUserInput(replaceURL); _saveAvatarOverrideUrl = true; } @@ -1516,7 +1500,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocus(); - if (cmdOptionExists(argc, constArgv, "--system-cursor")) { + if (parser->isSet("system-cursor")) { _preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); } showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); @@ -1585,21 +1569,23 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo } }); +#if defined(Q_OS_ANDROID) || defined(DISABLE_QML) connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() { -#if !defined(Q_OS_ANDROID) && !defined(DISABLE_QML) - // Do not show login dialog if requested not to on the command line - QString hifiNoLoginCommandLineKey = QString("--").append(HIFI_NO_LOGIN_COMMAND_LINE_KEY); - int index = arguments().indexOf(hifiNoLoginCommandLineKey); - if (index != -1 || _disableLoginScreen) { - resumeAfterLoginDialogActionTaken(); - return; - } - - showLoginScreen(); -#else resumeAfterLoginDialogActionTaken(); -#endif }); +#else + // Do not show login dialog if requested not to on the command line + if (_disableLoginScreen || parser->isSet("no-login-suggestion")) { + connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() { + resumeAfterLoginDialogActionTaken(); + }); + } else { + connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() { + showLoginScreen(); + resumeAfterLoginDialogActionTaken(); + }); + } +#endif // Initialize the user interface and menu system // Needs to happen AFTER the render engine initialization to access its configuration @@ -1961,13 +1947,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice()); } - QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH); - _defaultScriptsLocation.setPath(getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str())); + if (parser->isSet("scripts")) { + _defaultScriptsLocation.setPath(parser->value("scripts")); // Already done in "main.cpp". + _overrideDefaultScriptsLocation = true; + } else { + _overrideDefaultScriptsLocation = false; + } // Make sure we don't time out during slow operations at startup updateHeartbeat(); - loadSettings(); + loadSettings(parser); updateVerboseLogging(); @@ -2018,11 +2008,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo // If launched from Steam, let it handle updates - const QString HIFI_NO_UPDATER_COMMAND_LINE_KEY = "--no-updater"; - bool noUpdater = arguments().indexOf(HIFI_NO_UPDATER_COMMAND_LINE_KEY) != -1; bool buildCanUpdate = BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable || BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Master; - if (!noUpdater && buildCanUpdate) { + if (!parser->isSet("no-updater") && buildCanUpdate) { constexpr auto INSTALLER_TYPE_CLIENT_ONLY = "client_only"; auto applicationUpdater = DependencyManager::set(); @@ -2191,8 +2179,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo static int NEARBY_AVATAR_RADIUS_METERS = 10; // setup the stats interval depending on if the 1s faster hearbeat was requested - static const QString FAST_STATS_ARG = "--fast-heartbeat"; - static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000; + static int SEND_STATS_INTERVAL_MS; + if (parser->isSet("fast-heartbeat")) { + SEND_STATS_INTERVAL_MS = 1000; + } else { + SEND_STATS_INTERVAL_MS = 10000; + } static glm::vec3 lastAvatarPosition = myAvatar->getWorldPosition(); static glm::mat4 lastHMDHeadPose = getHMDSensorPose(); @@ -4022,16 +4014,11 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { QString addressLookupString; // when --url in command line, teleport to location - QCommandLineParser parser; - QCommandLineOption urlOption("url", "", "value"); - parser.addOption(urlOption); - parser.parse(arguments()); - if (parser.isSet(urlOption)) { - QUrl url = QUrl(parser.value(urlOption)); - if (url.scheme() == URL_SCHEME_VIRCADIAAPP) { - Setting::Handle("startUpApp").set(url.path()); + if (!_urlParam.isEmpty()) { // Not sure if format supported by isValid(). + if (_urlParam.scheme() == URL_SCHEME_VIRCADIAAPP) { + Setting::Handle("startUpApp").set(_urlParam.path()); } else { - addressLookupString = url.toString(); + addressLookupString = _urlParam.toString(); } } @@ -5514,7 +5501,7 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa return exportEntities(filename, entities, ¢er); } -void Application::loadSettings() { +void Application::loadSettings(const QCommandLineParser* parser) { sessionRunTime.set(0); // Just clean living. We're about to saveSettings, which will update value. DependencyManager::get()->loadSettings(); @@ -5544,7 +5531,7 @@ void Application::loadSettings() { } bool isFirstPerson = false; - if (arguments().contains("--no-launcher")) { + if (parser->isSet("no-launcher")) { const auto& displayPlugins = pluginManager->getDisplayPlugins(); for (const auto& plugin : displayPlugins) { if (!plugin->isHmd()) { @@ -5849,7 +5836,7 @@ void Application::resumeAfterLoginDialogActionTaken() { scriptEngines->reloadLocalFiles(); // if the --scripts command-line argument was used. - if (_defaultScriptsLocation.exists() && (arguments().indexOf(QString("--").append(SCRIPTS_SWITCH))) != -1) { + if (_overrideDefaultScriptsLocation && _defaultScriptsLocation.exists()) { scriptEngines->loadDefaultScripts(); scriptEngines->defaultScriptsLocationOverridden(true); } else { @@ -5869,7 +5856,7 @@ void Application::resumeAfterLoginDialogActionTaken() { // Set last parameter to exit interface when the test script finishes, if so requested DependencyManager::get()->loadScript(testScript, false, false, false, false, quitWhenFinished); // This is done so we don't get a "connection time-out" message when we haven't passed in a URL. - if (arguments().contains("--url")) { + if (!_urlParam.isEmpty()) { auto reply = SandboxUtils::getStatus(); connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); }); } @@ -8831,31 +8818,21 @@ void Application::sendLambdaEvent(const std::function& f) { } } -void Application::initPlugins(const QStringList& arguments) { - QCommandLineOption display("display", "Preferred displays", "displays"); - QCommandLineOption disableDisplays("disable-displays", "Displays to disable", "displays"); - QCommandLineOption disableInputs("disable-inputs", "Inputs to disable", "inputs"); - - QCommandLineParser parser; - parser.addOption(display); - parser.addOption(disableDisplays); - parser.addOption(disableInputs); - parser.parse(arguments); - - if (parser.isSet(display)) { - auto preferredDisplays = parser.value(display).split(',', Qt::SkipEmptyParts); +void Application::initPlugins(const QCommandLineParser* parser) { + if (parser->isSet("display")) { + auto preferredDisplays = parser->value("display").split(',', Qt::SkipEmptyParts); qInfo() << "Setting prefered display plugins:" << preferredDisplays; PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays); } - if (parser.isSet(disableDisplays)) { - auto disabledDisplays = parser.value(disableDisplays).split(',', Qt::SkipEmptyParts); + if (parser->isSet("disable-displays")) { + auto disabledDisplays = parser->value("disableDisplays").split(',', Qt::SkipEmptyParts); qInfo() << "Disabling following display plugins:" << disabledDisplays; PluginManager::getInstance()->disableDisplays(disabledDisplays); } - if (parser.isSet(disableInputs)) { - auto disabledInputs = parser.value(disableInputs).split(',', Qt::SkipEmptyParts); + if (parser->isSet("disable-inputs")) { + auto disabledInputs = parser->value("disableInputs").split(',', Qt::SkipEmptyParts); qInfo() << "Disabling following input plugins:" << disabledInputs; PluginManager::getInstance()->disableInputs(disabledInputs); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 215473ddfbc..8815f48e3cb 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -15,6 +15,7 @@ #include +#include #include #include #include @@ -22,6 +23,7 @@ #include #include + #include #include @@ -96,8 +98,6 @@ namespace controller { static const QString RUNNING_MARKER_FILENAME = "Interface.running"; -static const QString SCRIPTS_SWITCH = "scripts"; -static const QString HIFI_NO_LOGIN_COMMAND_LINE_KEY = "no-login-suggestion"; class Application; #if defined(qApp) @@ -130,10 +130,15 @@ class Application : public QApplication, virtual DisplayPluginPointer getActiveDisplayPlugin() const override; // FIXME? Empty methods, do we still need them? - static void initPlugins(const QStringList& arguments); + static void initPlugins(const QCommandLineParser* parser); static void shutdownPlugins(); - Application(int& argc, char** argv, QElapsedTimer& startup_time, bool runningMarkerExisted); + Application( + int& argc, char** argv, + const QCommandLineParser* parser, + QElapsedTimer& startup_time, + bool runningMarkerExisted + ); ~Application(); void postLambdaEvent(const std::function& f) override; @@ -505,7 +510,7 @@ private slots: void notifyPacketVersionMismatch(); - void loadSettings(); + void loadSettings(const QCommandLineParser* parser); void saveSettings() const; void setFailedToConnectToEntityServer(); @@ -705,6 +710,8 @@ private slots: QPointer _logDialog; QPointer _entityScriptServerLogDialog; QDir _defaultScriptsLocation; + // If above is only set by parameter, below is unnecessary. + bool _overrideDefaultScriptsLocation; TouchEvent _lastTouchEvent; @@ -830,6 +837,8 @@ private slots: bool quitWhenFinished { false }; + QUrl _urlParam; + bool _showTrackedObjects { false }; bool _prevShowTrackedObjects { false }; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index e30aa70f227..e750ec5d98e 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -78,7 +78,8 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption protocolVersionOption( "protocolVersion", - "Displays the protocol version." + "Writes the protocol version base64 signature to a file?", + "path" // Why?? ); QCommandLineOption noUpdaterOption( "no-updater", @@ -106,11 +107,11 @@ int main(int argc, const char* argv[]) { "set test cache .", "dir" ); - //QCommandLineOption scriptsOption( - // "scripts", - // "Set path for defaultScripts.", - // "dir" - //); // Use this once SCRIPTS_SWITCH is removed. + QCommandLineOption scriptsOption( + "scripts", + "Set path for defaultScripts.", + "dir" + ); QCommandLineOption allowMultipleInstancesOption( "allowMultipleInstances", "Allow multiple instances to run." @@ -122,11 +123,13 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption disableDisplaysOption( "disable-displays", - "Displays to disable." + "Displays to disable.", + "string" ); QCommandLineOption disableInputsOption( "disable-inputs", - "Inputs to disable." + "Inputs to disable.", + "string" ); QCommandLineOption suppressSettingsResetOption( "suppress-settings-reset", @@ -175,11 +178,11 @@ int main(int argc, const char* argv[]) { "no-launcher", "Do not execute the launcher." ); - QCommandLineOption overrideScriptsPathOption( + /*QCommandLineOption overrideScriptsPathOption( SCRIPTS_SWITCH, "Set scripts ", "path" - ); + );*/ QCommandLineOption defaultScriptOverrideOption( "defaultScriptsOverride", "Override defaultsScripts.js.", @@ -195,6 +198,10 @@ int main(int argc, const char* argv[]) { "Set user display name .", "string" ); + QCommandLineOption noLoginOption( + "no-login-suggestion", + "Do not show log-in dialogue." + ); QCommandLineOption traceFileOption( "traceFile", "Probably writes a trace to a file?", @@ -210,6 +217,24 @@ int main(int argc, const char* argv[]) { "Forces client instance's clock to skew for demonstration purposes.", "value" ); + QCommandLineOption testScriptOption( + "testScript", + "Undocumented. Accepts parameter as U.R.L.", + "string" + ); + QCommandLineOption testResultsLocationOption( + "testResultsLocation", + "Undocumented", + "path" + ); + QCommandLineOption quitWhenFinishedOption( + "quitWhenFinished", + "Only works if \"--testScript\" is provided." + ); // Should probably also work on testResultsLocationOption. + QCommandLineOption fastHeartbeatOption( + "fast-heartbeat", + "Change stats polling interval from 10000ms to 1000ms." + ); // "--qmljsdebugger", which appears in output from "--help-all". // Those below don't seem to be optional. // --ignore-gpu-blacklist @@ -223,7 +248,7 @@ int main(int argc, const char* argv[]) { parser.addOption(listenPortOption); parser.addOption(serverContentPathOption); parser.addOption(overrideAppLocalDataPathOption); - //parser.addOption(scriptsOption); // Use this once SCRIPTS_SWITCH is removed. + parser.addOption(scriptsOption); // Also known as "overrideScriptsPathOption"? parser.addOption(allowMultipleInstancesOption); parser.addOption(displaysOption); parser.addOption(disableDisplaysOption); @@ -239,15 +264,17 @@ int main(int argc, const char* argv[]) { parser.addOption(setBookmarkOption); parser.addOption(forceCrashReportingOption); parser.addOption(noLauncherOption); - parser.addOption(overrideScriptsPathOption); // Remove this along with SCRIPTS_SWITCH. parser.addOption(responseTokensOption); parser.addOption(displayNameOption); parser.addOption(defaultScriptOverrideOption); parser.addOption(traceFileOption); parser.addOption(traceDurationOption); parser.addOption(clockSkewOption); + parser.addOption(testScriptOption); + parser.addOption(testResultsLocationOption); + parser.addOption(quitWhenFinishedOption); + parser.addOption(fastHeartbeatOption); - QStringList arguments; QString applicationPath; // A temporary application instance is needed to get the location of the running executable // Tests using high_resolution_clock show that this takes about 30-50 microseconds (on my machine, YMMV) @@ -257,7 +284,6 @@ int main(int argc, const char* argv[]) { QCoreApplication tempApp(argc, const_cast(argv)); parser.process(QCoreApplication::arguments()); // Must be run after QCoreApplication is initalised. - arguments = parser.positionalArguments(); // Must be run after parser processes arguments. #ifdef Q_OS_OSX if (QFileInfo::exists(QCoreApplication::applicationDirPath() + "/../../../config.json")) { @@ -386,12 +412,13 @@ int main(int argc, const char* argv[]) { // this needs to be done here in main, as the mechanism for setting the // scripts directory appears not to work. See the bug report // https://highfidelity.fogbugz.com/f/cases/5759/Issues-changing-scripts-directory-in-ScriptsEngine - if (parser.isSet(overrideScriptsPathOption)) { + // It is currently also done in "Application.cpp". Not sure if necessary. + /*if (parser.isSet(overrideScriptsPathOption)) { QDir scriptsPath(parser.value(overrideScriptsPathOption)); if (scriptsPath.exists()) { PathUtils::defaultScriptsLocation(scriptsPath.path()); } - } + }*/ if (instanceMightBeRunning) { // Try to connect and send message to existing interface instance @@ -469,7 +496,7 @@ int main(int argc, const char* argv[]) { // Oculus initialization MUST PRECEDE OpenGL context creation. // The nature of the Application constructor means this has to be either here, // or in the main window ctor, before GL startup. - Application::initPlugins(arguments); + Application::initPlugins(&parser); #ifdef Q_OS_WIN // If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec @@ -517,7 +544,7 @@ int main(int argc, const char* argv[]) { PROFILE_SYNC_END(startup, "main startup", ""); PROFILE_SYNC_BEGIN(startup, "app full ctor", ""); - Application app(argcExtended, const_cast(argvExtended.data()), startupTime, runningMarkerExisted); + Application app(argcExtended, const_cast(argvExtended.data()), &parser, startupTime, runningMarkerExisted); PROFILE_SYNC_END(startup, "app full ctor", ""); #if defined(Q_OS_LINUX) From b59795e71c70be2c81f9888b089fec546a0a39ec Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 26 Oct 2021 12:29:21 -0700 Subject: [PATCH 10/23] Removed duplicate "--version". --- interface/src/Application.cpp | 5 +---- interface/src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5484d2b838d..9800df88b1b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -752,10 +752,7 @@ bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, b reportAndQuit("--protocolVersion", [&](FILE* fp) { auto version = protocolVersionsSignatureBase64(); fputs(version.toLatin1().data(), fp); - }); // This doesn't seem to work. - /*reportAndQuit("--version", [&](FILE* fp) { - fputs(BuildInfo::VERSION.toLatin1().data(), fp); - });*/ + }); const int listenPort = parser->isSet("listenPort") ? parser->value("listenPort").toInt() : INVALID_PORT; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index e750ec5d98e..c858d4b48a7 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -216,7 +216,7 @@ int main(int argc, const char* argv[]) { "clockSkew", "Forces client instance's clock to skew for demonstration purposes.", "value" - ); + ); // This should probably be removed. QCommandLineOption testScriptOption( "testScript", "Undocumented. Accepts parameter as U.R.L.", From 8394bb57b2625bd7b8dbb75beaa3a05a609d9ac2 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 26 Oct 2021 17:29:15 -0700 Subject: [PATCH 11/23] Fixed handling of traceFileOption. Moved last to main. --- interface/src/Application.cpp | 25 ------------------------- interface/src/main.cpp | 33 +++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 39 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9800df88b1b..40ce5351f88 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -723,36 +723,11 @@ extern DisplayPluginList getDisplayPlugins(); extern InputPluginList getInputPlugins(); extern void saveInputPluginSettings(const InputPluginList& plugins); -// Parameters used for running tests from the command line - bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, bool runningMarkerExisted) { const char** constArgv = const_cast(argv); qInstallMessageHandler(messageHandler); - // HRS: I could not figure out how to move these any earlier in startup, so when using this option, be sure to also supply - // --allowMultipleInstances - auto reportAndQuit = [&](const char* commandSwitch, std::function report) { - // Do something about this: - const char* reportfile = getCmdOption(argc, constArgv, commandSwitch); - // Reports to the specified file, because stdout is set up to be captured for logging. - if (reportfile) { - FILE* fp = fopen(reportfile, "w"); - if (fp) { - report(fp); - fclose(fp); - if (!runningMarkerExisted) { // don't leave ours around - RunningMarker runingMarker(RUNNING_MARKER_FILENAME); - runingMarker.deleteRunningMarkerFile(); // happens in deleter, but making the side-effect explicit. - } - _exit(0); - } - } - }; - reportAndQuit("--protocolVersion", [&](FILE* fp) { - auto version = protocolVersionsSignatureBase64(); - fputs(version.toLatin1().data(), fp); - }); const int listenPort = parser->isSet("listenPort") ? parser->value("listenPort").toInt() : INVALID_PORT; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index c858d4b48a7..a62f8399d63 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -64,8 +64,6 @@ int main(int argc, const char* argv[]) { setupHifiApplication(BuildInfo::INTERFACE_NAME); - // grep -E 'getCmdOption|QCommandLineOption|cmdOptionExists' 'interface/src/Application.cpp' - QCommandLineParser parser; parser.setApplicationDescription("Overte"); QCommandLineOption helpOption = parser.addHelpOption(); @@ -178,11 +176,6 @@ int main(int argc, const char* argv[]) { "no-launcher", "Do not execute the launcher." ); - /*QCommandLineOption overrideScriptsPathOption( - SCRIPTS_SWITCH, - "Set scripts ", - "path" - );*/ QCommandLineOption defaultScriptOverrideOption( "defaultScriptsOverride", "Override defaultsScripts.js.", @@ -204,12 +197,12 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption traceFileOption( "traceFile", - "Probably writes a trace to a file?", + "Probably writes a trace to a file? Only works if \"--traceDuration\" is specified.", "path" ); QCommandLineOption traceDurationOption( "traceDuration", - "Only works if \"--traceFile\" is provided.", + "Probably a number of seconds? Only works if \"--traceFile\" is specified.", "value" ); QCommandLineOption clockSkewOption( @@ -230,7 +223,7 @@ int main(int argc, const char* argv[]) { QCommandLineOption quitWhenFinishedOption( "quitWhenFinished", "Only works if \"--testScript\" is provided." - ); // Should probably also work on testResultsLocationOption. + ); // Should probably also be made to work on testResultsLocationOption. QCommandLineOption fastHeartbeatOption( "fast-heartbeat", "Change stats polling interval from 10000ms to 1000ms." @@ -306,6 +299,17 @@ int main(int argc, const char* argv[]) { parser.showHelp(); Q_UNREACHABLE(); } + if (parser.isSet(protocolVersionOption)) { + FILE* fp = fopen(parser.value(protocolVersionOption).toStdString().c_str(), "w"); + if (fp) { + fputs(protocolVersionsSignatureBase64().toStdString().c_str(), fp); + fclose(fp); + return 0; + } else { + qWarning() << "Failed to open file specified for --protocolVersion."; + return 1; + } + } static const QString APPLICATION_CONFIG_FILENAME = "config.json"; QDir applicationDir(applicationPath); @@ -345,15 +349,16 @@ int main(int argc, const char* argv[]) { // Early check for --traceFile argument auto tracer = DependencyManager::set(); const char * traceFile = nullptr; - float traceDuration; + float traceDuration = 0.0f; if (parser.isSet(traceFileOption)) { traceFile = parser.value(traceFileOption).toStdString().c_str(); if (parser.isSet(traceDurationOption)) { traceDuration = parser.value(traceDurationOption).toFloat(); + tracer->startTracing(); } else { - traceDuration = 0.0f; + qWarning() << "\"--traceDuration\" must be specified along with \"--traceFile\"..."; + return 1; } - tracer->startTracing(); } PROFILE_SYNC_BEGIN(startup, "main startup", ""); @@ -410,7 +415,7 @@ int main(int argc, const char* argv[]) { instanceMightBeRunning = false; } // this needs to be done here in main, as the mechanism for setting the - // scripts directory appears not to work. See the bug report + // scripts directory appears not to work. See the bug report (dead link) // https://highfidelity.fogbugz.com/f/cases/5759/Issues-changing-scripts-directory-in-ScriptsEngine // It is currently also done in "Application.cpp". Not sure if necessary. /*if (parser.isSet(overrideScriptsPathOption)) { From ce20730b9459d7e29f5aca7fc979b8cface5af4f Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 26 Oct 2021 17:55:14 -0700 Subject: [PATCH 12/23] Made help info more helpful. --- interface/src/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index a62f8399d63..f0bd07a8e3a 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -72,7 +72,7 @@ int main(int argc, const char* argv[]) { QCommandLineOption urlOption( "url", "Start at specified URL location.", - "value" + "string" ); QCommandLineOption protocolVersionOption( "protocolVersion", @@ -85,11 +85,11 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption checkMinSpecOption( "checkMinSpec", - "Check if machine meets minimum specifications." + "Check if machine meets minimum specifications. The program will run if check passes." ); QCommandLineOption runServerOption( "runServer", - "Whether to run the server." + "Run the server." ); QCommandLineOption listenPortOption( "listenPort", @@ -97,12 +97,12 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption serverContentPathOption( "serverContentPath", - "Where to find server content .", + "Path to find server content.", // What content?? "serverContentPath" ); // This data type will not be familiar to users. QCommandLineOption overrideAppLocalDataPathOption( "cache", - "set test cache .", + "Set test cache.", "dir" ); QCommandLineOption scriptsOption( @@ -203,12 +203,12 @@ int main(int argc, const char* argv[]) { QCommandLineOption traceDurationOption( "traceDuration", "Probably a number of seconds? Only works if \"--traceFile\" is specified.", - "value" + "number" ); QCommandLineOption clockSkewOption( "clockSkew", "Forces client instance's clock to skew for demonstration purposes.", - "value" + "integer" ); // This should probably be removed. QCommandLineOption testScriptOption( "testScript", From daecc1563ba1f599930cb0a4e54fea8abe8af5d1 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Tue, 26 Oct 2021 18:32:24 -0700 Subject: [PATCH 13/23] Notational changes. --- interface/src/Application.cpp | 2 +- interface/src/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 40ce5351f88..ac47934d16a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1920,7 +1920,7 @@ Application::Application( } if (parser->isSet("scripts")) { - _defaultScriptsLocation.setPath(parser->value("scripts")); // Already done in "main.cpp". + _defaultScriptsLocation.setPath(parser->value("scripts")); // Might need to be done in "main.cpp". _overrideDefaultScriptsLocation = true; } else { _overrideDefaultScriptsLocation = false; diff --git a/interface/src/main.cpp b/interface/src/main.cpp index f0bd07a8e3a..4230a32f83b 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -107,7 +107,7 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption scriptsOption( "scripts", - "Set path for defaultScripts.", + "Set path for defaultScripts. These are probably scripts that run automatically.", "dir" ); QCommandLineOption allowMultipleInstancesOption( From c6cb01c4b89dfac5a28d143ad9a8726395e7cb34 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Wed, 27 Oct 2021 14:09:23 -0700 Subject: [PATCH 14/23] Re-enabled overrideScriptsPathOption. --- interface/src/main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 4230a32f83b..78b12993b30 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -176,8 +176,13 @@ int main(int argc, const char* argv[]) { "no-launcher", "Do not execute the launcher." ); + QCommandLineOption overrideScriptsPathOption( + "overrideScriptsPath", + "Probably specifies where to look for scripts.", + "string" + ); QCommandLineOption defaultScriptOverrideOption( - "defaultScriptsOverride", + "defaultScriptOverride", "Override defaultsScripts.js.", "string" ); @@ -241,7 +246,7 @@ int main(int argc, const char* argv[]) { parser.addOption(listenPortOption); parser.addOption(serverContentPathOption); parser.addOption(overrideAppLocalDataPathOption); - parser.addOption(scriptsOption); // Also known as "overrideScriptsPathOption"? + parser.addOption(scriptsOption); parser.addOption(allowMultipleInstancesOption); parser.addOption(displaysOption); parser.addOption(disableDisplaysOption); @@ -259,6 +264,7 @@ int main(int argc, const char* argv[]) { parser.addOption(noLauncherOption); parser.addOption(responseTokensOption); parser.addOption(displayNameOption); + parser.addOption(overrideScriptsPathOption); parser.addOption(defaultScriptOverrideOption); parser.addOption(traceFileOption); parser.addOption(traceDurationOption); @@ -417,13 +423,12 @@ int main(int argc, const char* argv[]) { // this needs to be done here in main, as the mechanism for setting the // scripts directory appears not to work. See the bug report (dead link) // https://highfidelity.fogbugz.com/f/cases/5759/Issues-changing-scripts-directory-in-ScriptsEngine - // It is currently also done in "Application.cpp". Not sure if necessary. - /*if (parser.isSet(overrideScriptsPathOption)) { + if (parser.isSet(overrideScriptsPathOption)) { QDir scriptsPath(parser.value(overrideScriptsPathOption)); if (scriptsPath.exists()) { PathUtils::defaultScriptsLocation(scriptsPath.path()); } - }*/ + } if (instanceMightBeRunning) { // Try to connect and send message to existing interface instance From 694f093658d55e84bfab156691650ce6144da7d2 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Fri, 5 Nov 2021 17:58:35 -0700 Subject: [PATCH 15/23] Fixed quibbles. --- interface/src/Application.cpp | 2 +- interface/src/main.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ac47934d16a..049abb2d50c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1921,7 +1921,7 @@ Application::Application( if (parser->isSet("scripts")) { _defaultScriptsLocation.setPath(parser->value("scripts")); // Might need to be done in "main.cpp". - _overrideDefaultScriptsLocation = true; + _overrideDefaultScriptsLocation = true; } else { _overrideDefaultScriptsLocation = false; } diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 78b12993b30..5c7ba837f43 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -93,7 +93,8 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption listenPortOption( "listenPort", - "Port to listen on." + "Port to listen on.", + "port_number" ); QCommandLineOption serverContentPathOption( "serverContentPath", @@ -151,15 +152,18 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption concurrentDownloadsOption( "concurrent-downloads", - "Maximum concurrent resource downloads. Default is 16, except for Android where it is 4." + "Maximum concurrent resource downloads. Default is 16, except for Android where it is 4.", + "integer" ); QCommandLineOption avatarURLOption( "avatarURL", - "Override the avatar U.R.L." + "Override the avatar U.R.L.", + "url" ); QCommandLineOption replaceAvatarURLOption( "replace-avatar-url", - "Replaces the avatar U.R.L. When used with --avatarURL, this takes precedence." + "Replaces the avatar U.R.L. When used with --avatarURL, this takes precedence.", + "url" ); QCommandLineOption setBookmarkOption( "setBookmark", From 72df49412fce7c4ff312d67ba6ad5398ca016207 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Fri, 5 Nov 2021 18:25:10 -0700 Subject: [PATCH 16/23] Fixed a spacing. --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 049abb2d50c..cbc46910180 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1923,7 +1923,7 @@ Application::Application( _defaultScriptsLocation.setPath(parser->value("scripts")); // Might need to be done in "main.cpp". _overrideDefaultScriptsLocation = true; } else { - _overrideDefaultScriptsLocation = false; + _overrideDefaultScriptsLocation = false; } // Make sure we don't time out during slow operations at startup From 759b428b346c341758ce247b8c1f778218c398c0 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Fri, 5 Nov 2021 18:27:15 -0700 Subject: [PATCH 17/23] Fixed a different kind of spacing. --- interface/src/Application.h | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/Application.h b/interface/src/Application.h index 8815f48e3cb..ab56daf67a2 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -23,7 +23,6 @@ #include #include - #include #include From b11b173b60e1db570f9bbfe6afcbd9782d456d91 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sat, 20 Nov 2021 12:34:34 -0800 Subject: [PATCH 18/23] Changes parser pointer to reference. --- interface/src/Application.cpp | 78 +++++++++++++++++------------------ interface/src/Application.h | 6 +-- interface/src/main.cpp | 4 +- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cbc46910180..a7f5c0b0628 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -723,24 +723,24 @@ extern DisplayPluginList getDisplayPlugins(); extern InputPluginList getInputPlugins(); extern void saveInputPluginSettings(const InputPluginList& plugins); -bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, bool runningMarkerExisted) { +bool setupEssentials(int& argc, char** argv, const QCommandLineParser& parser, bool runningMarkerExisted) { const char** constArgv = const_cast(argv); qInstallMessageHandler(messageHandler); - const int listenPort = parser->isSet("listenPort") ? parser->value("listenPort").toInt() : INVALID_PORT; + const int listenPort = parser.isSet("listenPort") ? parser.value("listenPort").toInt() : INVALID_PORT; - bool suppressPrompt = parser->isSet("suppress-settings-reset"); + bool suppressPrompt = parser.isSet("suppress-settings-reset"); // set the OCULUS_STORE property so the oculus plugin can know if we ran from the Oculus Store - qApp->setProperty(hifi::properties::OCULUS_STORE, parser->isSet("oculus-store")); + qApp->setProperty(hifi::properties::OCULUS_STORE, parser.isSet("oculus-store")); // emulate standalone device - qApp->setProperty(hifi::properties::STANDALONE, parser->isSet("standalone")); + qApp->setProperty(hifi::properties::STANDALONE, parser.isSet("standalone")); // Ignore any previous crashes if running from command line with a test script. - bool inTestMode = parser->isSet("testScript"); + bool inTestMode = parser.isSet("testScript"); bool previousSessionCrashed { false }; if (!inTestMode) { @@ -748,8 +748,8 @@ bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, b } // get dir to use for cache - if (parser->isSet("cache")) { - qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, parser->value("cache")); + if (parser.isSet("cache")) { + qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, parser.value("cache")); } { @@ -791,7 +791,7 @@ bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, b QCoreApplication::addLibraryPath(audioDLLPath); #endif - QString defaultScriptsOverrideOption = parser->value("defaultScriptsOverride"); + QString defaultScriptsOverrideOption = parser.value("defaultScriptsOverride"); DependencyManager::registerInheritance(); DependencyManager::registerInheritance(); @@ -917,7 +917,7 @@ bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, b }); - QString setBookmarkValue = parser->value("setBookmark"); + QString setBookmarkValue = parser.value("setBookmark"); if (!setBookmarkValue.isEmpty()) { // Bookmarks are expected to be in a name=url form. // An `=` character in the name or url is unsupported. @@ -976,7 +976,7 @@ QSharedPointer getOffscreenUI() { Application::Application( int& argc, char** argv, - const QCommandLineParser* parser, + const QCommandLineParser& parser, QElapsedTimer& startupTimer, bool runningMarkerExisted ) : @@ -1023,8 +1023,8 @@ Application::Application( LogHandler::getInstance().setupRepeatedMessageFlusher(); { - if (parser->isSet("testScript")) { - QString testScriptPath = parser->value("testScript"); + if (parser.isSet("testScript")) { + QString testScriptPath = parser.value("testScript"); // If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file // This is done so as not break previous command line scripts if (testScriptPath.left(HIFI_URL_SCHEME_HTTP.length()) == HIFI_URL_SCHEME_HTTP || @@ -1035,20 +1035,20 @@ Application::Application( setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); } - if (parser->isSet("quitWhenFinished")) { + if (parser.isSet("quitWhenFinished")) { quitWhenFinished = true; } } - if (parser->isSet("testResultsLocation")) { + if (parser.isSet("testResultsLocation")) { // Set test snapshot location only if it is a writeable directory - QString path = parser->value("testResultsLocation"); + QString path = parser.value("testResultsLocation"); QFileInfo fileInfo(path); if (fileInfo.isDir() && fileInfo.isWritable()) { TestScriptingInterface::getInstance()->setTestResultsLocation(path); } } - _urlParam = parser->value("url"); + _urlParam = parser.value("url"); } { @@ -1114,7 +1114,7 @@ Application::Application( auto addressManager = DependencyManager::get(); addressManager->moveToThread(nodeList->thread()); - if (parser->isSet("disableWatchdog")) { + if (parser.isSet("disableWatchdog")) { DISABLE_WATCHDOG = true; } // Set up a watchdog thread to intentionally crash the application on deadlocks @@ -1435,9 +1435,9 @@ Application::Application( connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent); connect(&_entityEditSender, &EntityEditPacketSender::addingEntityWithCertificate, this, &Application::addingEntityWithCertificate); - if (parser->isSet("concurrent-downloads")) { + if (parser.isSet("concurrent-downloads")) { bool success; - uint32_t concurrentDownloads = parser->value("concurrent-downloads").toUInt(&success); + uint32_t concurrentDownloads = parser.value("concurrent-downloads").toUInt(&success); if (!success) { concurrentDownloads = MAX_CONCURRENT_RESOURCE_DOWNLOADS; } @@ -1446,15 +1446,15 @@ Application::Application( // perhaps override the avatar url. Since we will test later for validity // we don't need to do so here. - if (parser->isSet("avatarURL")) { - _avatarOverrideUrl = QUrl::fromUserInput(parser->value("avatarURL")); + if (parser.isSet("avatarURL")) { + _avatarOverrideUrl = QUrl::fromUserInput(parser.value("avatarURL")); } // If someone specifies both --avatarURL and --replaceAvatarURL, // the replaceAvatarURL wins. So only set the _overrideUrl if this // does have a non-empty string. - if (parser->isSet("replaceAvatarURL")) { - QString replaceURL = parser->value("replaceAvatarURL"); + if (parser.isSet("replaceAvatarURL")) { + QString replaceURL = parser.value("replaceAvatarURL"); _avatarOverrideUrl = QUrl::fromUserInput(replaceURL); _saveAvatarOverrideUrl = true; } @@ -1472,7 +1472,7 @@ Application::Application( _glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocus(); - if (parser->isSet("system-cursor")) { + if (parser.isSet("system-cursor")) { _preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); } showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); @@ -1547,7 +1547,7 @@ Application::Application( }); #else // Do not show login dialog if requested not to on the command line - if (_disableLoginScreen || parser->isSet("no-login-suggestion")) { + if (_disableLoginScreen || parser.isSet("no-login-suggestion")) { connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() { resumeAfterLoginDialogActionTaken(); }); @@ -1919,8 +1919,8 @@ Application::Application( userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice()); } - if (parser->isSet("scripts")) { - _defaultScriptsLocation.setPath(parser->value("scripts")); // Might need to be done in "main.cpp". + if (parser.isSet("scripts")) { + _defaultScriptsLocation.setPath(parser.value("scripts")); // Might need to be done in "main.cpp". _overrideDefaultScriptsLocation = true; } else { _overrideDefaultScriptsLocation = false; @@ -1982,7 +1982,7 @@ Application::Application( // If launched from Steam, let it handle updates bool buildCanUpdate = BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable || BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Master; - if (!parser->isSet("no-updater") && buildCanUpdate) { + if (!parser.isSet("no-updater") && buildCanUpdate) { constexpr auto INSTALLER_TYPE_CLIENT_ONLY = "client_only"; auto applicationUpdater = DependencyManager::set(); @@ -2152,7 +2152,7 @@ Application::Application( // setup the stats interval depending on if the 1s faster hearbeat was requested static int SEND_STATS_INTERVAL_MS; - if (parser->isSet("fast-heartbeat")) { + if (parser.isSet("fast-heartbeat")) { SEND_STATS_INTERVAL_MS = 1000; } else { SEND_STATS_INTERVAL_MS = 10000; @@ -5473,7 +5473,7 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa return exportEntities(filename, entities, ¢er); } -void Application::loadSettings(const QCommandLineParser* parser) { +void Application::loadSettings(const QCommandLineParser& parser) { sessionRunTime.set(0); // Just clean living. We're about to saveSettings, which will update value. DependencyManager::get()->loadSettings(); @@ -5503,7 +5503,7 @@ void Application::loadSettings(const QCommandLineParser* parser) { } bool isFirstPerson = false; - if (parser->isSet("no-launcher")) { + if (parser.isSet("no-launcher")) { const auto& displayPlugins = pluginManager->getDisplayPlugins(); for (const auto& plugin : displayPlugins) { if (!plugin->isHmd()) { @@ -8790,21 +8790,21 @@ void Application::sendLambdaEvent(const std::function& f) { } } -void Application::initPlugins(const QCommandLineParser* parser) { - if (parser->isSet("display")) { - auto preferredDisplays = parser->value("display").split(',', Qt::SkipEmptyParts); +void Application::initPlugins(const QCommandLineParser& parser) { + if (parser.isSet("display")) { + auto preferredDisplays = parser.value("display").split(',', Qt::SkipEmptyParts); qInfo() << "Setting prefered display plugins:" << preferredDisplays; PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays); } - if (parser->isSet("disable-displays")) { - auto disabledDisplays = parser->value("disableDisplays").split(',', Qt::SkipEmptyParts); + if (parser.isSet("disable-displays")) { + auto disabledDisplays = parser.value("disableDisplays").split(',', Qt::SkipEmptyParts); qInfo() << "Disabling following display plugins:" << disabledDisplays; PluginManager::getInstance()->disableDisplays(disabledDisplays); } - if (parser->isSet("disable-inputs")) { - auto disabledInputs = parser->value("disableInputs").split(',', Qt::SkipEmptyParts); + if (parser.isSet("disable-inputs")) { + auto disabledInputs = parser.value("disableInputs").split(',', Qt::SkipEmptyParts); qInfo() << "Disabling following input plugins:" << disabledInputs; PluginManager::getInstance()->disableInputs(disabledInputs); } diff --git a/interface/src/Application.h b/interface/src/Application.h index ab56daf67a2..cd323eef08f 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -129,12 +129,12 @@ class Application : public QApplication, virtual DisplayPluginPointer getActiveDisplayPlugin() const override; // FIXME? Empty methods, do we still need them? - static void initPlugins(const QCommandLineParser* parser); + static void initPlugins(const QCommandLineParser& parser); static void shutdownPlugins(); Application( int& argc, char** argv, - const QCommandLineParser* parser, + const QCommandLineParser& parser, QElapsedTimer& startup_time, bool runningMarkerExisted ); @@ -509,7 +509,7 @@ private slots: void notifyPacketVersionMismatch(); - void loadSettings(const QCommandLineParser* parser); + void loadSettings(const QCommandLineParser& parser); void saveSettings() const; void setFailedToConnectToEntityServer(); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 5c7ba837f43..63a366d296e 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -510,7 +510,7 @@ int main(int argc, const char* argv[]) { // Oculus initialization MUST PRECEDE OpenGL context creation. // The nature of the Application constructor means this has to be either here, // or in the main window ctor, before GL startup. - Application::initPlugins(&parser); + Application::initPlugins(parser); #ifdef Q_OS_WIN // If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec @@ -558,7 +558,7 @@ int main(int argc, const char* argv[]) { PROFILE_SYNC_END(startup, "main startup", ""); PROFILE_SYNC_BEGIN(startup, "app full ctor", ""); - Application app(argcExtended, const_cast(argvExtended.data()), &parser, startupTime, runningMarkerExisted); + Application app(argcExtended, const_cast(argvExtended.data()), parser, startupTime, runningMarkerExisted); PROFILE_SYNC_END(startup, "app full ctor", ""); #if defined(Q_OS_LINUX) From b844b1628570b774940db1b0461f73823f6fe97a Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sat, 20 Nov 2021 17:12:49 -0800 Subject: [PATCH 19/23] Requested fixes (hopefully). --- interface/src/Application.cpp | 42 ++++++++++++++++++----------------- interface/src/main.cpp | 20 ++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a7f5c0b0628..6c9c6402e00 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1337,25 +1337,27 @@ Application::Application( connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress); connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount); - connect(this, &Application::activeDisplayPluginChanged, this, [=](){ - qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode()); - auto displayPlugin = qApp->getActiveDisplayPlugin(); + if (parser.isSet("system-cursor")) { + _preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); - if (displayPlugin->isHmd()) { - if (_preferredCursor.get() == Cursor::Manager::getIconName(Cursor::Icon::RETICLE)) { - setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::RETICLE)); - } - else { - setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::ARROW)); + connect(this, &Application::activeDisplayPluginChanged, this, [=](){ + qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode()); + auto displayPlugin = qApp->getActiveDisplayPlugin(); + + if (displayPlugin->isHmd()) { + if (_preferredCursor.get() == Cursor::Manager::getIconName(Cursor::Icon::RETICLE)) { + setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::RETICLE)); + } else { + setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::ARROW)); + } + } else { + setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); } - } - else { - setPreferredCursor(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); - } - setCrashAnnotation("display_plugin", displayPlugin->getName().toStdString()); - setCrashAnnotation("hmd", displayPlugin->isHmd() ? "1" : "0"); - }); + setCrashAnnotation("display_plugin", displayPlugin->getName().toStdString()); + setCrashAnnotation("hmd", displayPlugin->isHmd() ? "1" : "0"); + }); + } connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode); connect(this, &Application::activeDisplayPluginChanged, this, [&](){ if (getLoginDialogPoppedUp()) { @@ -1472,9 +1474,9 @@ Application::Application( _glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocus(); - if (parser.isSet("system-cursor")) { + /*if (parser.isSet("system-cursor")) { // This is now done above, since the conditional was needed anyway. _preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); - } + }*/ showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); // enable mouse tracking; otherwise, we only get drag events @@ -5809,10 +5811,10 @@ void Application::resumeAfterLoginDialogActionTaken() { // if the --scripts command-line argument was used. if (_overrideDefaultScriptsLocation && _defaultScriptsLocation.exists()) { - scriptEngines->loadDefaultScripts(); + scriptEngines->loadScripts(); scriptEngines->defaultScriptsLocationOverridden(true); } else { - scriptEngines->loadScripts(); + scriptEngines->loadDefaultScripts(); } } diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 63a366d296e..471e866f323 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -65,7 +65,7 @@ int main(int argc, const char* argv[]) { setupHifiApplication(BuildInfo::INTERFACE_NAME); QCommandLineParser parser; - parser.setApplicationDescription("Overte"); + parser.setApplicationDescription("Overte -- A free/libre and open-source metaverse client"); QCommandLineOption helpOption = parser.addHelpOption(); QCommandLineOption versionOption = parser.addVersionOption(); @@ -148,7 +148,7 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption systemCursorOption( "system-cursor", - "Probably prevents changing the cursor when application has focus." + "Use the default system cursor." ); QCommandLineOption concurrentDownloadsOption( "concurrent-downloads", @@ -182,12 +182,12 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption overrideScriptsPathOption( "overrideScriptsPath", - "Probably specifies where to look for scripts.", + "Specifies path to default directory where the application will look for scripts to load.", "string" ); - QCommandLineOption defaultScriptOverrideOption( - "defaultScriptOverride", - "Override defaultsScripts.js.", + QCommandLineOption defaultScriptsOverrideOption( + "defaultScriptsOverride", + "Override default script to run automatically on start. Default is \"defaultsScripts.js\".", "string" ); QCommandLineOption responseTokensOption( @@ -206,13 +206,13 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption traceFileOption( "traceFile", - "Probably writes a trace to a file? Only works if \"--traceDuration\" is specified.", + "Writes a trace to a file in the documents folder. Only works if \"--traceDuration\" is specified.", "path" ); QCommandLineOption traceDurationOption( "traceDuration", - "Probably a number of seconds? Only works if \"--traceFile\" is specified.", - "number" + "Automatically quit interface after duration. Only works if \"--traceFile\" is specified.", + "seconds" ); QCommandLineOption clockSkewOption( "clockSkew", @@ -269,7 +269,7 @@ int main(int argc, const char* argv[]) { parser.addOption(responseTokensOption); parser.addOption(displayNameOption); parser.addOption(overrideScriptsPathOption); - parser.addOption(defaultScriptOverrideOption); + parser.addOption(defaultScriptsOverrideOption); parser.addOption(traceFileOption); parser.addOption(traceDurationOption); parser.addOption(clockSkewOption); From 97ed129a7344ccb0108e0215c3ddf0627c042f00 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sun, 21 Nov 2021 06:18:36 -0800 Subject: [PATCH 20/23] Swapped functions back. --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6c9c6402e00..cbebe496972 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5811,10 +5811,10 @@ void Application::resumeAfterLoginDialogActionTaken() { // if the --scripts command-line argument was used. if (_overrideDefaultScriptsLocation && _defaultScriptsLocation.exists()) { - scriptEngines->loadScripts(); + scriptEngines->loadDefaultScripts(); scriptEngines->defaultScriptsLocationOverridden(true); } else { - scriptEngines->loadDefaultScripts(); + scriptEngines->loadScripts(); } } From 4a76bd077565feb87e94bcc58eb94f5cbcd7fcbf Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sun, 21 Nov 2021 07:15:49 -0800 Subject: [PATCH 21/23] Added warning that --scripts does not seem to work. --- interface/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 471e866f323..e6906150370 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -108,7 +108,7 @@ int main(int argc, const char* argv[]) { ); QCommandLineOption scriptsOption( "scripts", - "Set path for defaultScripts. These are probably scripts that run automatically.", + "Set path for defaultScripts. These are probably scripts that run automatically. This parameter does not seem to work.", "dir" ); QCommandLineOption allowMultipleInstancesOption( From 4a74ba5b9fb7237e90ee9906b840b0d2a7fee8e3 Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Wed, 1 Dec 2021 14:49:34 -0800 Subject: [PATCH 22/23] Added warning that --no-launcher supposedly does not work. --- interface/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/main.cpp b/interface/src/main.cpp index e6906150370..aa314df944b 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -178,7 +178,7 @@ int main(int argc, const char* argv[]) { // Below are undocumented. QCommandLineOption noLauncherOption( "no-launcher", - "Do not execute the launcher." + "Supposedly does something for the server, unrelated to the application launcher. The feature may never have been implemented." ); QCommandLineOption overrideScriptsPathOption( "overrideScriptsPath", From 04a4437ace3008acd62ebf5f62ab1714be79988d Mon Sep 17 00:00:00 2001 From: Penguin-Guru Date: Sat, 28 May 2022 13:47:24 -0700 Subject: [PATCH 23/23] Removed comments. Changed a parameter type label. --- interface/src/Application.cpp | 3 --- interface/src/main.cpp | 6 +++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index cbebe496972..fd45ef77460 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1474,9 +1474,6 @@ Application::Application( _glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocus(); - /*if (parser.isSet("system-cursor")) { // This is now done above, since the conditional was needed anyway. - _preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); - }*/ showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); // enable mouse tracking; otherwise, we only get drag events diff --git a/interface/src/main.cpp b/interface/src/main.cpp index aa314df944b..e18312f8b72 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -77,7 +77,7 @@ int main(int argc, const char* argv[]) { QCommandLineOption protocolVersionOption( "protocolVersion", "Writes the protocol version base64 signature to a file?", - "path" // Why?? + "path" ); QCommandLineOption noUpdaterOption( "no-updater", @@ -99,8 +99,8 @@ int main(int argc, const char* argv[]) { QCommandLineOption serverContentPathOption( "serverContentPath", "Path to find server content.", // What content?? - "serverContentPath" - ); // This data type will not be familiar to users. + "path" + ); QCommandLineOption overrideAppLocalDataPathOption( "cache", "Set test cache.",