From 7fb8cd01dd124578df4e8daf26e4ea8949dd87d0 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 13 Jul 2023 00:23:15 +0200 Subject: [PATCH] NimCompilerCleanStep: Employ task tree for running Task-number: QTCREATORBUG-29168 Change-Id: I9f7b0d6c00fcfdc62baa5e17dc337ccc75d2e4bd Reviewed-by: Reviewed-by: hjk --- .../nim/project/nimcompilercleanstep.cpp | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/src/plugins/nim/project/nimcompilercleanstep.cpp b/src/plugins/nim/project/nimcompilercleanstep.cpp index 4e2c51446a8..fe3e4dfa4b2 100644 --- a/src/plugins/nim/project/nimcompilercleanstep.cpp +++ b/src/plugins/nim/project/nimcompilercleanstep.cpp @@ -9,6 +9,8 @@ #include +#include + #include #include @@ -16,6 +18,7 @@ #include using namespace ProjectExplorer; +using namespace Tasking; using namespace Utils; namespace Nim { @@ -37,8 +40,7 @@ public: private: bool init() final; - void doRun() final; - void doCancel() final {} // Can be left empty. The run() function hardly does anything. + GroupItem runRecipe() final; bool removeCacheDirectory(); bool removeOutFilePath(); @@ -49,35 +51,36 @@ private: bool NimCompilerCleanStep::init() { - FilePath buildDir = buildDirectory(); - bool result = buildDir.exists(); - if (result) + if (!BuildStep::init()) + return false; + const FilePath buildDir = buildDirectory(); + const bool exists = buildDir.exists(); + if (exists) m_buildDir = buildDir; - return result; + return exists; } -void NimCompilerCleanStep::doRun() +GroupItem NimCompilerCleanStep::runRecipe() { - if (!m_buildDir.exists()) { - emit addOutput(Tr::tr("Build directory \"%1\" does not exist.").arg(m_buildDir.toUserOutput()), OutputFormat::ErrorMessage); - emit finished(false); - return; - } - - if (!removeCacheDirectory()) { - emit addOutput(Tr::tr("Failed to delete the cache directory."), OutputFormat::ErrorMessage); - emit finished(false); - return; - } - - if (!removeOutFilePath()) { - emit addOutput(Tr::tr("Failed to delete the out file."), OutputFormat::ErrorMessage); - emit finished(false); - return; - } - - emit addOutput(Tr::tr("Clean step completed successfully."), OutputFormat::NormalMessage); - emit finished(true); + const auto onSetup = [this] { + if (!m_buildDir.exists()) { + emit addOutput(Tr::tr("Build directory \"%1\" does not exist.") + .arg(m_buildDir.toUserOutput()), OutputFormat::ErrorMessage); + return false; + } + if (!removeCacheDirectory()) { + emit addOutput(Tr::tr("Failed to delete the cache directory."), + OutputFormat::ErrorMessage); + return false; + } + if (!removeOutFilePath()) { + emit addOutput(Tr::tr("Failed to delete the out file."), OutputFormat::ErrorMessage); + return false; + } + emit addOutput(Tr::tr("Clean step completed successfully."), OutputFormat::NormalMessage); + return true; + }; + return Sync(onSetup); } bool NimCompilerCleanStep::removeCacheDirectory()