From 6570895c0b388801285c5a5a72c21e7e4a0f07ea Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 2 Feb 2023 00:30:51 +0100 Subject: [PATCH] TaskTree: Some cosmetic polishing after last refactoring Get rid of unneeded local variable. Use boolean OR instead of bitwise OR (regressed during refactoring). Assert on parentContainer pointer inside task's done handler. Amends 5dc4cd837f271d5f297d3f5efc3ca4a2bfee6bbe Change-Id: I2517b80ae894317c52d46326681021d1133fbae9 Reviewed-by: Qt CI Bot Reviewed-by: Marcus Tillmanns --- src/libs/utils/tasktree.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libs/utils/tasktree.cpp b/src/libs/utils/tasktree.cpp index ee6f113fc35..1cd4fd3f018 100644 --- a/src/libs/utils/tasktree.cpp +++ b/src/libs/utils/tasktree.cpp @@ -461,8 +461,7 @@ TaskAction TaskContainer::startChildren(int nextChild) { QTC_CHECK(isRunning()); GuardLocker locker(m_runtimeData->m_startGuard); - const int childCount = m_constData.m_children.size(); - for (int i = nextChild; i < childCount; ++i) { + for (int i = nextChild; i < m_constData.m_children.size(); ++i) { const int limit = m_runtimeData->currentLimit(); if (i >= limit) break; @@ -489,9 +488,8 @@ TaskAction TaskContainer::childDone(bool success) { QTC_CHECK(isRunning()); const int limit = m_runtimeData->currentLimit(); // Read before bumping m_doneCount and stop() - const bool shouldStop - = (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnDone && success) - | (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnError && !success); + const bool shouldStop = (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnDone && success) + || (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnError && !success); if (shouldStop) stop(); @@ -499,7 +497,7 @@ TaskAction TaskContainer::childDone(bool success) const bool updatedSuccess = m_runtimeData->updateSuccessBit(success); const TaskAction startAction = (shouldStop || m_runtimeData->m_doneCount == m_constData.m_children.size()) - ? toTaskAction(updatedSuccess) : TaskAction::Continue; + ? toTaskAction(updatedSuccess) : TaskAction::Continue; if (isStarting()) return startAction; @@ -552,7 +550,7 @@ TaskAction TaskNode::start() invokeEndHandler(success); disconnect(m_task.get(), &TaskInterface::done, this, nullptr); m_task.release()->deleteLater(); - QTC_ASSERT(parentContainer()->isRunning(), return); + QTC_ASSERT(parentContainer() && parentContainer()->isRunning(), return); if (parentContainer()->isStarting()) *unwindAction = toTaskAction(success); else