diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index d80d596ac..8aa17d8e5 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -983,6 +983,11 @@ namespace BlackCore "shared"); this->addParserOption(m_cmdSharedDir); + // Skip single application check + m_cmdSkipSingleApp = QCommandLineOption({ "skipsa", "skipsingleapp" }, + QCoreApplication::translate("application", "Skip the single app.test.")); + this->addParserOption(m_cmdSkipSingleApp); + // reset caches upfront m_cmdClearCache = QCommandLineOption({ "ccache", "clearcache" }, QCoreApplication::translate("application", "Clear (reset) the caches.")); @@ -990,7 +995,7 @@ namespace BlackCore // test crashpad upload m_cmdTestCrashpad = QCommandLineOption({ "testcp", "testcrashpad" }, - QCoreApplication::translate("application", "Simulate crashpad situation.")); + QCoreApplication::translate("application", "Trigger crashpad situation.")); this->addParserOption(m_cmdTestCrashpad); } @@ -1321,6 +1326,11 @@ namespace BlackCore return this->isParserOptionSet("installer"); } + bool CApplication::skipSingleApplicationCheck() const + { + return this->isParserOptionSet(m_cmdSkipSingleApp); + } + bool CApplication::isParserOptionSet(const QCommandLineOption &option) const { return m_parser.isSet(option); @@ -1354,12 +1364,6 @@ namespace BlackCore return false; } - if (m_singleApplication && m_alreadyRunning) - { - this->cmdLineErrorMessage("Program must only run once"); - return false; - } - // we call parse because we also want to display a GUI error message when applicable const QStringList args(QCoreApplication::instance()->arguments()); if (!m_parser.parse(args)) @@ -1368,6 +1372,12 @@ namespace BlackCore return false; } + if (m_singleApplication && m_alreadyRunning && !this->skipSingleApplicationCheck()) + { + this->cmdLineErrorMessage("Program must only run once"); + return false; + } + // help/version if (m_parser.isSet(m_cmdHelp)) { diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 8eb9e0747..328e342fd 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -270,6 +270,9 @@ namespace BlackCore //! Called by installer? bool isInstallerOptionSet() const; + //! Skip the single application check + bool skipSingleApplicationCheck() const; + //! Delegates to QCommandLineParser::isSet bool isParserOptionSet(const QCommandLineOption &option) const; @@ -625,21 +628,22 @@ namespace BlackCore static void registerMetadata(); // cmd parsing - QList m_allOptions; //!< all registered options - QCommandLineParser m_parser; //!< cmd parser - QCommandLineOption m_cmdHelp {"help"}; //!< help option - QCommandLineOption m_cmdVersion {"version"}; //!< version option - QCommandLineOption m_cmdDBusAddress {"emptyDBus"}; //!< DBus address - QCommandLineOption m_cmdDevelopment {"dev"}; //!< Development flag - QCommandLineOption m_cmdSharedDir {"shared"}; //!< Shared directory - QCommandLineOption m_cmdClearCache {"clearcache"}; //!< Clear cache - QCommandLineOption m_cmdTestCrashpad {"testcrashpad"}; //!< Test a crasphpad upload - bool m_parsed = false; //!< Parsing accomplished? - bool m_started = false; //!< started with success? - bool m_singleApplication = true; //!< only one instance of that application - bool m_alreadyRunning = false; //!< Application already running - std::atomic_bool m_shutdown { false }; //!< is being shutdown? - std::atomic_bool m_shutdownInProgress { false }; //!< shutdown in progress? + QList m_allOptions; //!< All registered options + QCommandLineParser m_parser; //!< cmd parser + QCommandLineOption m_cmdHelp {"help"}; //!< help option + QCommandLineOption m_cmdVersion {"version"}; //!< version option + QCommandLineOption m_cmdDBusAddress {"emptyDBus"}; //!< DBus address + QCommandLineOption m_cmdDevelopment {"dev"}; //!< Development flag + QCommandLineOption m_cmdSharedDir {"shared"}; //!< Shared directory + QCommandLineOption m_cmdClearCache {"clearcache"}; //!< Clear cache + QCommandLineOption m_cmdTestCrashpad {"testcrashpad"}; //!< Test a crasphpad upload + QCommandLineOption m_cmdSkipSingleApp {"skipsa"}; //!< Skip test for single application + bool m_parsed = false; //!< Parsing accomplished? + bool m_started = false; //!< Started with success? + bool m_singleApplication = true; //!< Only one instance of that application + bool m_alreadyRunning = false; //!< Application already running + std::atomic_bool m_shutdown { false }; //!< Is being shutdown? + std::atomic_bool m_shutdownInProgress { false }; //!< shutdown in progress? private: //! Problem with network access manager