From 870a1dca4dda30e678bb24806de8aa0b08994d31 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 13 Jul 2023 00:04:11 +0200 Subject: [PATCH] CopyStepBase: Employ task tree for running Task-number: QTCREATORBUG-29168 Change-Id: Ie97c20da77ca8b1d93bf4725fa5bd4a7710be55b Reviewed-by: hjk --- src/plugins/projectexplorer/copystep.cpp | 37 ++++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/plugins/projectexplorer/copystep.cpp b/src/plugins/projectexplorer/copystep.cpp index 6d5aef64db0..0d5c012016d 100644 --- a/src/plugins/projectexplorer/copystep.cpp +++ b/src/plugins/projectexplorer/copystep.cpp @@ -7,7 +7,9 @@ #include "projectexplorertr.h" #include +#include +using namespace Tasking; using namespace Utils; namespace ProjectExplorer::Internal { @@ -33,31 +35,34 @@ public: protected: bool init() final { + if (!BuildStep::init()) + return false; m_source = m_sourceAspect(); m_target = m_targetAspect(); return m_source.exists(); } - void doRun() final - { - // FIXME: asyncCopy does not handle directories yet. - QTC_ASSERT(m_source.isFile(), emit finished(false)); - m_source.asyncCopy(m_target, this, [this](const expected_str &cont) { - if (!cont) { - addOutput(cont.error(), OutputFormat::ErrorMessage); - addOutput(Tr::tr("Copying failed."), OutputFormat::ErrorMessage); - emit finished(false); - } else { - addOutput(Tr::tr("Copying finished."), OutputFormat::NormalMessage); - emit finished(true); - } - }); - } - FilePathAspect m_sourceAspect{this}; FilePathAspect m_targetAspect{this}; private: + GroupItem runRecipe() final + { + const auto onSetup = [this](FileStreamer &streamer) { + QTC_ASSERT(m_source.isFile(), return SetupResult::StopWithError); + streamer.setSource(m_source); + streamer.setDestination(m_target); + return SetupResult::Continue; + }; + const auto onDone = [this](const FileStreamer &) { + addOutput(Tr::tr("Copying finished."), OutputFormat::NormalMessage); + }; + const auto onError = [this](const FileStreamer &) { + addOutput(Tr::tr("Copying failed."), OutputFormat::ErrorMessage); + }; + return FileStreamerTask(onSetup, onDone, onError); + } + FilePath m_source; FilePath m_target; };