From 857531b0119e8f7706a73181937c139af1100d2b Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 13 Aug 2020 15:41:28 +1000 Subject: [PATCH] core: don't start if help or version args are used --- app/core.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/core.cpp b/app/core.cpp index 945bd3f2b..4ab066d1c 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -84,16 +84,13 @@ int Core::execute(QCoreApplication* a) { int exit_code = 1; - // Start core - OLIVE_NAMESPACE::Core::instance()->Start(); - // // Parse command line arguments // QCommandLineParser parser; - parser.addHelpOption(); - parser.addVersionOption(); + QCommandLineOption help_option = parser.addHelpOption(); + QCommandLineOption version_option = parser.addVersionOption(); // Project from command line option // FIXME: What's the correct way to make a visually "optional" positional argument, or is manually adding square @@ -111,6 +108,14 @@ int Core::execute(QCoreApplication* a) // Parse options parser.process(*a); + if (parser.isSet(help_option) || parser.isSet(version_option)) { + // These options don't launch any of the application proper + return a->exec(); + } + + // Start core + OLIVE_NAMESPACE::Core::instance()->Start(); + QStringList args = parser.positionalArguments(); // Detect project to load on startup @@ -142,8 +147,6 @@ int Core::execute(QCoreApplication* a) } - - // Clear core memory OLIVE_NAMESPACE::Core::instance()->Stop();