forked from qt-creator/qt-creator
TaskTree: Keep list of unique_ptr for owned children
Change-Id: Ib6bc1efa647b4e48b1a4188de480f06bc4e7699e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -1228,10 +1228,8 @@ public:
|
|||||||
m_taskContainer.m_taskTreePrivate->callDoneHandler(storage, storageId);
|
m_taskContainer.m_taskTreePrivate->callDoneHandler(storage, storageId);
|
||||||
storage.m_storageData->deleteStorage(storageId);
|
storage.m_storageData->deleteStorage(storageId);
|
||||||
}
|
}
|
||||||
qDeleteAll(m_children);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static QList<int> createStorages(const TaskContainer &container);
|
static QList<int> createStorages(const TaskContainer &container);
|
||||||
bool isStarting() const { return m_startGuard.isLocked(); }
|
bool isStarting() const { return m_startGuard.isLocked(); }
|
||||||
bool updateSuccessBit(bool success);
|
bool updateSuccessBit(bool success);
|
||||||
@@ -1243,7 +1241,7 @@ public:
|
|||||||
TaskRuntimeContainer *m_parentContainer = nullptr; // Not owning.
|
TaskRuntimeContainer *m_parentContainer = nullptr; // Not owning.
|
||||||
const QList<int> m_storageIdList;
|
const QList<int> m_storageIdList;
|
||||||
|
|
||||||
QList<TaskRuntimeNode *> m_children; // Owning.
|
std::vector<std::unique_ptr<TaskRuntimeNode>> m_children; // Owning.
|
||||||
bool m_successBit = true;
|
bool m_successBit = true;
|
||||||
bool m_callStorageDoneHandlersOnDestruction = false;
|
bool m_callStorageDoneHandlersOnDestruction = false;
|
||||||
int m_doneCount = 0;
|
int m_doneCount = 0;
|
||||||
@@ -1401,10 +1399,9 @@ int TaskRuntimeContainer::currentLimit() const
|
|||||||
|
|
||||||
void TaskRuntimeContainer::deleteChild(TaskRuntimeNode *node)
|
void TaskRuntimeContainer::deleteChild(TaskRuntimeNode *node)
|
||||||
{
|
{
|
||||||
const int index = m_children.indexOf(node);
|
std::remove_if(m_children.begin(), m_children.end(), [node](const auto &ptr) {
|
||||||
QT_CHECK(index >= 0);
|
return ptr.get() == node;
|
||||||
m_children[index] = nullptr;
|
});
|
||||||
delete node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupResult TaskTreePrivate::start(TaskRuntimeContainer *container)
|
SetupResult TaskTreePrivate::start(TaskRuntimeContainer *container)
|
||||||
@@ -1460,7 +1457,7 @@ SetupResult TaskTreePrivate::startChildren(TaskRuntimeContainer *container, int
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
TaskRuntimeNode *newTask = new TaskRuntimeNode(container->m_taskContainer.m_children.at(i), container);
|
TaskRuntimeNode *newTask = new TaskRuntimeNode(container->m_taskContainer.m_children.at(i), container);
|
||||||
container->m_children.append(newTask);
|
container->m_children.emplace_back(newTask);
|
||||||
|
|
||||||
const SetupResult startAction = start(newTask);
|
const SetupResult startAction = start(newTask);
|
||||||
if (startAction == SetupResult::Continue)
|
if (startAction == SetupResult::Continue)
|
||||||
@@ -1504,17 +1501,13 @@ SetupResult TaskTreePrivate::childDone(TaskRuntimeContainer *container, bool suc
|
|||||||
|
|
||||||
void TaskTreePrivate::stop(TaskRuntimeContainer *container)
|
void TaskTreePrivate::stop(TaskRuntimeContainer *container)
|
||||||
{
|
{
|
||||||
const int limit = container->currentLimit();
|
for (auto &child : container->m_children) {
|
||||||
for (int i = 0; i < limit; ++i) {
|
|
||||||
if (i == container->m_children.size())
|
|
||||||
break;
|
|
||||||
TaskRuntimeNode *child = container->m_children.at(i);
|
|
||||||
if (child)
|
if (child)
|
||||||
stop(child);
|
stop(child.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
int skippedTaskCount = 0;
|
int skippedTaskCount = 0;
|
||||||
for (int i = limit; i < int(container->m_taskContainer.m_children.size()); ++i)
|
for (int i = container->currentLimit(); i < int(container->m_taskContainer.m_children.size()); ++i)
|
||||||
skippedTaskCount += container->m_taskContainer.m_children.at(i).taskCount();
|
skippedTaskCount += container->m_taskContainer.m_children.at(i).taskCount();
|
||||||
|
|
||||||
// TODO: Handle progress well
|
// TODO: Handle progress well
|
||||||
|
Reference in New Issue
Block a user