diff --git a/src/libs/solutions/tasking/tasktreerunner.cpp b/src/libs/solutions/tasking/tasktreerunner.cpp index abaa0777191..d4accf217dd 100644 --- a/src/libs/solutions/tasking/tasktreerunner.cpp +++ b/src/libs/solutions/tasking/tasktreerunner.cpp @@ -9,13 +9,19 @@ namespace Tasking { TaskTreeRunner::~TaskTreeRunner() = default; -void TaskTreeRunner::start(const Group &recipe) +void TaskTreeRunner::start(const Group &recipe, + const SetupHandler &setupHandler, + const DoneHandler &doneHandler) { m_taskTree.reset(new TaskTree(recipe)); - connect(m_taskTree.get(), &TaskTree::done, this, [this](DoneWith result) { + connect(m_taskTree.get(), &TaskTree::done, this, [this, doneHandler](DoneWith result) { m_taskTree.release()->deleteLater(); + if (doneHandler) + doneHandler(result); emit done(result); }); + if (setupHandler) + setupHandler(m_taskTree.get()); emit aboutToStart(m_taskTree.get()); m_taskTree->start(); } diff --git a/src/libs/solutions/tasking/tasktreerunner.h b/src/libs/solutions/tasking/tasktreerunner.h index 95f6ddde14e..a0c0bad7b37 100644 --- a/src/libs/solutions/tasking/tasktreerunner.h +++ b/src/libs/solutions/tasking/tasktreerunner.h @@ -15,12 +15,17 @@ class TASKING_EXPORT TaskTreeRunner : public QObject Q_OBJECT public: + using SetupHandler = std::function; + using DoneHandler = std::function; + ~TaskTreeRunner(); bool isRunning() const { return bool(m_taskTree); } // When task tree is running it resets the old task tree. - void start(const Group &recipe); + void start(const Group &recipe, + const SetupHandler &setupHandler = {}, + const DoneHandler &doneHandler = {}); // TODO: rename to cancel(), also in TaskTree API, adapt docs. // When task tree is running it emits done(DoneWith::Cancel) synchronously.