TaskTree: Fix progress value on synchronous error

Add a test for it.

Change-Id: I86a1cf89efaef88b152c9db274ea712381cad407
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2025-01-07 13:48:37 +01:00
parent 4b956f20be
commit 103d67f821
2 changed files with 20 additions and 0 deletions

View File

@@ -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;

View File

@@ -3009,6 +3009,25 @@ void tst_Tasking::testTree_data()
<< TestData{storage, root, {}, 1, DoneWith::Success, 0};
}
{
class CustomTaskAdapter : public TaskAdapter<bool> // bool is dummy
{
private:
void start() final { emit done(DoneResult::Error); }
};
using CustomTask = CustomTask<CustomTaskAdapter>;
// 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 {