RecipeRunner: Make cancellation more general

Make it possible to continue cleanup tasks after the canceled()
signal has been sent.

Change-Id: I8c59549fdb30fa9bf8a800ce3835c12e2d204553
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-03-10 17:57:47 +01:00
parent 5785323883
commit c0a4077f61
3 changed files with 17 additions and 6 deletions

View File

@@ -1964,7 +1964,15 @@ Canceler canceler()
void RecipeRunner::start() void RecipeRunner::start()
{ {
QTC_CHECK(!m_taskTreeRunner.isRunning()); QTC_CHECK(!m_taskTreeRunner.isRunning());
m_taskTreeRunner.start(m_recipe, {}, [this](DoneWith result) {
const Group recipe {
runStorage(),
onGroupSetup([this] { connect(this, &RecipeRunner::canceled,
runStorage().activeStorage(), &RunInterface::canceled); }),
m_recipe
};
m_taskTreeRunner.start(recipe, {}, [this](DoneWith result) {
if (result == DoneWith::Success) if (result == DoneWith::Success)
reportStopped(); reportStopped();
else else
@@ -1975,8 +1983,7 @@ void RecipeRunner::start()
void RecipeRunner::stop() void RecipeRunner::stop()
{ {
m_taskTreeRunner.cancel(); emit canceled();
reportStopped();
} }
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -298,7 +298,6 @@ public:
explicit ProcessRunnerFactory(const QList<Utils::Id> &runConfig); explicit ProcessRunnerFactory(const QList<Utils::Id> &runConfig);
}; };
PROJECTEXPLORER_EXPORT PROJECTEXPLORER_EXPORT
void addOutputParserFactory(const std::function<Utils::OutputLineParser *(Target *)> &); void addOutputParserFactory(const std::function<Utils::OutputLineParser *(Target *)> &);
@@ -318,12 +317,17 @@ PROJECTEXPLORER_EXPORT Canceler canceler();
class PROJECTEXPLORER_EXPORT RecipeRunner final : public RunWorker class PROJECTEXPLORER_EXPORT RecipeRunner final : public RunWorker
{ {
Q_OBJECT
public: public:
explicit RecipeRunner(RunControl *runControl) explicit RecipeRunner(RunControl *runControl)
: RunWorker(runControl) {} : RunWorker(runControl) {}
void setRecipe(const Tasking::Group &recipe) { m_recipe = recipe; } void setRecipe(const Tasking::Group &recipe) { m_recipe = recipe; }
signals:
void canceled();
private: private:
void start() final; void start() final;
void stop() final; void stop() final;

View File

@@ -84,13 +84,13 @@ Group slog2InfoRecipe(RunControl *runControl)
storage->processRemainingLogData(); storage->processRemainingLogData();
}; };
return { return Group {
storage, storage,
ProcessTask(onTestSetup, onTestDone, CallDoneIf::Error), ProcessTask(onTestSetup, onTestDone, CallDoneIf::Error),
ProcessTask(onLaunchTimeSetup, onLaunchTimeDone, CallDoneIf::Success), ProcessTask(onLaunchTimeSetup, onLaunchTimeDone, CallDoneIf::Success),
ProcessTask(onLogSetup, onLogError, CallDoneIf::Error), ProcessTask(onLogSetup, onLogError, CallDoneIf::Error),
onGroupDone(onCanceled, CallDoneIf::Error) onGroupDone(onCanceled, CallDoneIf::Error)
}; }.withCancel(canceler());
} }
void SlogData::processRemainingLogData() void SlogData::processRemainingLogData()