From 308e7ba2aaee07ba3ad113b17865cf2166a02b56 Mon Sep 17 00:00:00 2001 From: Simon Perret Date: Thu, 25 Jul 2024 12:09:00 +0200 Subject: [PATCH] fix: do not run tests if the path to the directory doesn't exist --- src/core/knutcore.cpp | 6 ++++-- src/core/knutcore.h | 2 +- src/main.cpp | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/knutcore.cpp b/src/core/knutcore.cpp index 8099d7bb..b66a1f0b 100644 --- a/src/core/knutcore.cpp +++ b/src/core/knutcore.cpp @@ -44,7 +44,7 @@ KnutCore::KnutCore(InternalTag, QObject *parent) spdlog::cfg::load_env_levels(); } -void KnutCore::process(const QStringList &arguments) +bool KnutCore::process(const QStringList &arguments) { // Parse command line options QCommandLineParser parser; @@ -102,6 +102,7 @@ void KnutCore::process(const QStringList &arguments) } else { spdlog::error("KnutCore::process - Root directory: {}, does not exist. Cannot open a new project!", pathDir.absolutePath()); + return false; } } @@ -140,10 +141,11 @@ void KnutCore::process(const QStringList &arguments) qApp->exit(value.toInt()); }, Qt::QueuedConnection); - return; + return true; } doParse(parser); + return true; } void KnutCore::initParser(QCommandLineParser &parser) const diff --git a/src/core/knutcore.h b/src/core/knutcore.h index 92367a31..22fbbad1 100644 --- a/src/core/knutcore.h +++ b/src/core/knutcore.h @@ -26,7 +26,7 @@ class KnutCore : public QObject public: explicit KnutCore(QObject *parent = nullptr); - void process(const QStringList &arguments); + bool process(const QStringList &arguments); protected: // Used to disambiguate the internal constructor diff --git a/src/main.cpp b/src/main.cpp index 9cf26b22..84bcd11a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,8 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(gui); Gui::KnutMain knut; - knut.process(app.arguments()); - - return app.exec(); + if (knut.process(app.arguments())) + return app.exec(); + else + return 1; }