From 103d67f821481d33b502b69a96dd2eb8bcf35b58 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 7 Jan 2025 13:48:37 +0100 Subject: [PATCH] TaskTree: Fix progress value on synchronous error Add a test for it. Change-Id: I86a1cf89efaef88b152c9db274ea712381cad407 Reviewed-by: hjk --- src/libs/solutions/tasking/tasktree.cpp | 1 + tests/auto/solutions/tasking/tst_tasking.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/libs/solutions/tasking/tasktree.cpp b/src/libs/solutions/tasking/tasktree.cpp index 02340d6fc80..5c740bb0686 100644 --- a/src/libs/solutions/tasking/tasktree.cpp +++ b/src/libs/solutions/tasking/tasktree.cpp @@ -2271,6 +2271,7 @@ void TaskTreePrivate::startChildren(RuntimeContainer *container) if (task->m_setupResult == SetupResult::Continue) continue; + task->m_parentIteration->deleteChild(task.get()); childDone(iteration, task->m_setupResult == SetupResult::StopWithSuccess); if (container->m_parentTask->m_setupResult != SetupResult::Continue) return; diff --git a/tests/auto/solutions/tasking/tst_tasking.cpp b/tests/auto/solutions/tasking/tst_tasking.cpp index 57fb59a1bcc..ea5e74636c4 100644 --- a/tests/auto/solutions/tasking/tst_tasking.cpp +++ b/tests/auto/solutions/tasking/tst_tasking.cpp @@ -3009,6 +3009,25 @@ void tst_Tasking::testTree_data() << TestData{storage, root, {}, 1, DoneWith::Success, 0}; } + { + class CustomTaskAdapter : public TaskAdapter // bool is dummy + { + private: + void start() final { emit done(DoneResult::Error); } + }; + + using CustomTask = CustomTask; + + // Check if progress is updated correctly on error when the 1st task finishes synchonously. + const Group root { + storage, + CustomTask(), + createSuccessTask(1) + }; + QTest::newRow("ProgressOnSynchronousError") + << TestData{storage, root, {}, 2, DoneWith::Error, 0}; + } + { const auto recipe = [storage, createSuccessTask](bool withTask) { return Group {