Changes parser pointer to reference.

This commit is contained in:
Penguin-Guru 2021-11-20 12:34:34 -08:00
parent 759b428b34
commit b11b173b60
3 changed files with 44 additions and 44 deletions

View file

@ -723,24 +723,24 @@ extern DisplayPluginList getDisplayPlugins();
extern InputPluginList getInputPlugins(); extern InputPluginList getInputPlugins();
extern void saveInputPluginSettings(const InputPluginList& plugins); 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<const char**>(argv); const char** constArgv = const_cast<const char**>(argv);
qInstallMessageHandler(messageHandler); 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 // 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 // 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. // 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 }; bool previousSessionCrashed { false };
if (!inTestMode) { if (!inTestMode) {
@ -748,8 +748,8 @@ bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, b
} }
// get dir to use for cache // get dir to use for cache
if (parser->isSet("cache")) { if (parser.isSet("cache")) {
qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, parser->value("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); QCoreApplication::addLibraryPath(audioDLLPath);
#endif #endif
QString defaultScriptsOverrideOption = parser->value("defaultScriptsOverride"); QString defaultScriptsOverrideOption = parser.value("defaultScriptsOverride");
DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();
@ -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()) { if (!setBookmarkValue.isEmpty()) {
// Bookmarks are expected to be in a name=url form. // Bookmarks are expected to be in a name=url form.
// An `=` character in the name or url is unsupported. // An `=` character in the name or url is unsupported.
@ -976,7 +976,7 @@ QSharedPointer<OffscreenUi> getOffscreenUI() {
Application::Application( Application::Application(
int& argc, char** argv, int& argc, char** argv,
const QCommandLineParser* parser, const QCommandLineParser& parser,
QElapsedTimer& startupTimer, QElapsedTimer& startupTimer,
bool runningMarkerExisted bool runningMarkerExisted
) : ) :
@ -1023,8 +1023,8 @@ Application::Application(
LogHandler::getInstance().setupRepeatedMessageFlusher(); LogHandler::getInstance().setupRepeatedMessageFlusher();
{ {
if (parser->isSet("testScript")) { if (parser.isSet("testScript")) {
QString testScriptPath = parser->value("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 // 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 // This is done so as not break previous command line scripts
if (testScriptPath.left(HIFI_URL_SCHEME_HTTP.length()) == HIFI_URL_SCHEME_HTTP || 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)); setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath));
} }
if (parser->isSet("quitWhenFinished")) { if (parser.isSet("quitWhenFinished")) {
quitWhenFinished = true; quitWhenFinished = true;
} }
} }
if (parser->isSet("testResultsLocation")) { if (parser.isSet("testResultsLocation")) {
// Set test snapshot location only if it is a writeable directory // Set test snapshot location only if it is a writeable directory
QString path = parser->value("testResultsLocation"); QString path = parser.value("testResultsLocation");
QFileInfo fileInfo(path); QFileInfo fileInfo(path);
if (fileInfo.isDir() && fileInfo.isWritable()) { if (fileInfo.isDir() && fileInfo.isWritable()) {
TestScriptingInterface::getInstance()->setTestResultsLocation(path); TestScriptingInterface::getInstance()->setTestResultsLocation(path);
} }
} }
_urlParam = parser->value("url"); _urlParam = parser.value("url");
} }
{ {
@ -1114,7 +1114,7 @@ Application::Application(
auto addressManager = DependencyManager::get<AddressManager>(); auto addressManager = DependencyManager::get<AddressManager>();
addressManager->moveToThread(nodeList->thread()); addressManager->moveToThread(nodeList->thread());
if (parser->isSet("disableWatchdog")) { if (parser.isSet("disableWatchdog")) {
DISABLE_WATCHDOG = true; DISABLE_WATCHDOG = true;
} }
// Set up a watchdog thread to intentionally crash the application on deadlocks // 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::packetSent, this, &Application::packetSent);
connect(&_entityEditSender, &EntityEditPacketSender::addingEntityWithCertificate, this, &Application::addingEntityWithCertificate); connect(&_entityEditSender, &EntityEditPacketSender::addingEntityWithCertificate, this, &Application::addingEntityWithCertificate);
if (parser->isSet("concurrent-downloads")) { if (parser.isSet("concurrent-downloads")) {
bool success; bool success;
uint32_t concurrentDownloads = parser->value("concurrent-downloads").toUInt(&success); uint32_t concurrentDownloads = parser.value("concurrent-downloads").toUInt(&success);
if (!success) { if (!success) {
concurrentDownloads = MAX_CONCURRENT_RESOURCE_DOWNLOADS; concurrentDownloads = MAX_CONCURRENT_RESOURCE_DOWNLOADS;
} }
@ -1446,15 +1446,15 @@ Application::Application(
// perhaps override the avatar url. Since we will test later for validity // perhaps override the avatar url. Since we will test later for validity
// we don't need to do so here. // we don't need to do so here.
if (parser->isSet("avatarURL")) { if (parser.isSet("avatarURL")) {
_avatarOverrideUrl = QUrl::fromUserInput(parser->value("avatarURL")); _avatarOverrideUrl = QUrl::fromUserInput(parser.value("avatarURL"));
} }
// If someone specifies both --avatarURL and --replaceAvatarURL, // If someone specifies both --avatarURL and --replaceAvatarURL,
// the replaceAvatarURL wins. So only set the _overrideUrl if this // the replaceAvatarURL wins. So only set the _overrideUrl if this
// does have a non-empty string. // does have a non-empty string.
if (parser->isSet("replaceAvatarURL")) { if (parser.isSet("replaceAvatarURL")) {
QString replaceURL = parser->value("replaceAvatarURL"); QString replaceURL = parser.value("replaceAvatarURL");
_avatarOverrideUrl = QUrl::fromUserInput(replaceURL); _avatarOverrideUrl = QUrl::fromUserInput(replaceURL);
_saveAvatarOverrideUrl = true; _saveAvatarOverrideUrl = true;
} }
@ -1472,7 +1472,7 @@ Application::Application(
_glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocusPolicy(Qt::StrongFocus);
_glWidget->setFocus(); _glWidget->setFocus();
if (parser->isSet("system-cursor")) { if (parser.isSet("system-cursor")) {
_preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); _preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM));
} }
showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get()));
@ -1547,7 +1547,7 @@ Application::Application(
}); });
#else #else
// Do not show login dialog if requested not to on the command line // 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]() { connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() {
resumeAfterLoginDialogActionTaken(); resumeAfterLoginDialogActionTaken();
}); });
@ -1919,8 +1919,8 @@ Application::Application(
userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice()); userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice());
} }
if (parser->isSet("scripts")) { if (parser.isSet("scripts")) {
_defaultScriptsLocation.setPath(parser->value("scripts")); // Might need to be done in "main.cpp". _defaultScriptsLocation.setPath(parser.value("scripts")); // Might need to be done in "main.cpp".
_overrideDefaultScriptsLocation = true; _overrideDefaultScriptsLocation = true;
} else { } else {
_overrideDefaultScriptsLocation = false; _overrideDefaultScriptsLocation = false;
@ -1982,7 +1982,7 @@ Application::Application(
// If launched from Steam, let it handle updates // If launched from Steam, let it handle updates
bool buildCanUpdate = BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable bool buildCanUpdate = BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable
|| BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Master; || 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"; constexpr auto INSTALLER_TYPE_CLIENT_ONLY = "client_only";
auto applicationUpdater = DependencyManager::set<AutoUpdater>(); auto applicationUpdater = DependencyManager::set<AutoUpdater>();
@ -2152,7 +2152,7 @@ Application::Application(
// setup the stats interval depending on if the 1s faster hearbeat was requested // setup the stats interval depending on if the 1s faster hearbeat was requested
static int SEND_STATS_INTERVAL_MS; static int SEND_STATS_INTERVAL_MS;
if (parser->isSet("fast-heartbeat")) { if (parser.isSet("fast-heartbeat")) {
SEND_STATS_INTERVAL_MS = 1000; SEND_STATS_INTERVAL_MS = 1000;
} else { } else {
SEND_STATS_INTERVAL_MS = 10000; SEND_STATS_INTERVAL_MS = 10000;
@ -5473,7 +5473,7 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
return exportEntities(filename, entities, &center); return exportEntities(filename, entities, &center);
} }
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. sessionRunTime.set(0); // Just clean living. We're about to saveSettings, which will update value.
DependencyManager::get<AudioClient>()->loadSettings(); DependencyManager::get<AudioClient>()->loadSettings();
@ -5503,7 +5503,7 @@ void Application::loadSettings(const QCommandLineParser* parser) {
} }
bool isFirstPerson = false; bool isFirstPerson = false;
if (parser->isSet("no-launcher")) { if (parser.isSet("no-launcher")) {
const auto& displayPlugins = pluginManager->getDisplayPlugins(); const auto& displayPlugins = pluginManager->getDisplayPlugins();
for (const auto& plugin : displayPlugins) { for (const auto& plugin : displayPlugins) {
if (!plugin->isHmd()) { if (!plugin->isHmd()) {
@ -8790,21 +8790,21 @@ void Application::sendLambdaEvent(const std::function<void()>& f) {
} }
} }
void Application::initPlugins(const QCommandLineParser* parser) { void Application::initPlugins(const QCommandLineParser& parser) {
if (parser->isSet("display")) { if (parser.isSet("display")) {
auto preferredDisplays = parser->value("display").split(',', Qt::SkipEmptyParts); auto preferredDisplays = parser.value("display").split(',', Qt::SkipEmptyParts);
qInfo() << "Setting prefered display plugins:" << preferredDisplays; qInfo() << "Setting prefered display plugins:" << preferredDisplays;
PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays); PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays);
} }
if (parser->isSet("disable-displays")) { if (parser.isSet("disable-displays")) {
auto disabledDisplays = parser->value("disableDisplays").split(',', Qt::SkipEmptyParts); auto disabledDisplays = parser.value("disableDisplays").split(',', Qt::SkipEmptyParts);
qInfo() << "Disabling following display plugins:" << disabledDisplays; qInfo() << "Disabling following display plugins:" << disabledDisplays;
PluginManager::getInstance()->disableDisplays(disabledDisplays); PluginManager::getInstance()->disableDisplays(disabledDisplays);
} }
if (parser->isSet("disable-inputs")) { if (parser.isSet("disable-inputs")) {
auto disabledInputs = parser->value("disableInputs").split(',', Qt::SkipEmptyParts); auto disabledInputs = parser.value("disableInputs").split(',', Qt::SkipEmptyParts);
qInfo() << "Disabling following input plugins:" << disabledInputs; qInfo() << "Disabling following input plugins:" << disabledInputs;
PluginManager::getInstance()->disableInputs(disabledInputs); PluginManager::getInstance()->disableInputs(disabledInputs);
} }

View file

@ -129,12 +129,12 @@ public:
virtual DisplayPluginPointer getActiveDisplayPlugin() const override; virtual DisplayPluginPointer getActiveDisplayPlugin() const override;
// FIXME? Empty methods, do we still need them? // FIXME? Empty methods, do we still need them?
static void initPlugins(const QCommandLineParser* parser); static void initPlugins(const QCommandLineParser& parser);
static void shutdownPlugins(); static void shutdownPlugins();
Application( Application(
int& argc, char** argv, int& argc, char** argv,
const QCommandLineParser* parser, const QCommandLineParser& parser,
QElapsedTimer& startup_time, QElapsedTimer& startup_time,
bool runningMarkerExisted bool runningMarkerExisted
); );
@ -509,7 +509,7 @@ private slots:
void notifyPacketVersionMismatch(); void notifyPacketVersionMismatch();
void loadSettings(const QCommandLineParser* parser); void loadSettings(const QCommandLineParser& parser);
void saveSettings() const; void saveSettings() const;
void setFailedToConnectToEntityServer(); void setFailedToConnectToEntityServer();

View file

@ -510,7 +510,7 @@ int main(int argc, const char* argv[]) {
// Oculus initialization MUST PRECEDE OpenGL context creation. // Oculus initialization MUST PRECEDE OpenGL context creation.
// The nature of the Application constructor means this has to be either here, // The nature of the Application constructor means this has to be either here,
// or in the main window ctor, before GL startup. // or in the main window ctor, before GL startup.
Application::initPlugins(&parser); Application::initPlugins(parser);
#ifdef Q_OS_WIN #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 // 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_END(startup, "main startup", "");
PROFILE_SYNC_BEGIN(startup, "app full ctor", ""); PROFILE_SYNC_BEGIN(startup, "app full ctor", "");
Application app(argcExtended, const_cast<char**>(argvExtended.data()), &parser, startupTime, runningMarkerExisted); Application app(argcExtended, const_cast<char**>(argvExtended.data()), parser, startupTime, runningMarkerExisted);
PROFILE_SYNC_END(startup, "app full ctor", ""); PROFILE_SYNC_END(startup, "app full ctor", "");
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)