aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-11-22 15:21:45 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-11-23 12:59:29 +0000
commitdfd06ec1756b1a99ca887d5597c8f26d05d32ddf (patch)
treeef96ef3770c383f6db7c737a2e448377fdcb5f06 /src/libs
parent3468cd20ca8feeccf023091582d1390947822bd8 (diff)
TaskTree: Fix destruction of running task tree
Delete all storages that were created before. Change-Id: I8cbeb571424086b77fa7b19611c5b3f6cc1f4db1 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/utils/tasktree.cpp11
-rw-r--r--src/libs/utils/tasktree.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/src/libs/utils/tasktree.cpp b/src/libs/utils/tasktree.cpp
index 557b922ec7..55afcfdf40 100644
--- a/src/libs/utils/tasktree.cpp
+++ b/src/libs/utils/tasktree.cpp
@@ -17,6 +17,13 @@ bool TreeStorageBase::isValid() const
TreeStorageBase::TreeStorageBase(StorageConstructor ctor, StorageDestructor dtor)
: m_storageData(new StorageData{ctor, dtor}) { }
+TreeStorageBase::StorageData::~StorageData()
+{
+ QTC_CHECK(m_storageHash.isEmpty());
+ for (void *ptr : m_storageHash)
+ m_destructor(ptr);
+}
+
void *TreeStorageBase::activeStorageVoid() const
{
QTC_ASSERT(m_storageData->m_activeStorage, return nullptr);
@@ -283,6 +290,7 @@ TaskContainer::TaskContainer(TaskTreePrivate *taskTreePrivate, TaskContainer *pa
TaskContainer::~TaskContainer()
{
qDeleteAll(m_children);
+ deleteStorages();
}
void TaskContainer::start()
@@ -458,6 +466,7 @@ void TaskContainer::updateSuccessBit(bool success)
void TaskContainer::createStorages()
{
// TODO: Don't create new storage for already created storages with the same shared pointer.
+ QTC_CHECK(m_storageIdList.isEmpty());
for (int i = 0; i < m_storageList.size(); ++i)
m_storageIdList << m_storageList[i].createStorage();
@@ -467,7 +476,7 @@ void TaskContainer::deleteStorages()
{
// TODO: Do the opposite
- for (int i = 0; i < m_storageList.size(); ++i) // iterate in reverse order?
+ for (int i = 0; i < m_storageIdList.size(); ++i) // iterate in reverse order?
m_storageList[i].deleteStorage(m_storageIdList.value(i));
m_storageIdList.clear();
diff --git a/src/libs/utils/tasktree.h b/src/libs/utils/tasktree.h
index 1cd6c53330..bd31f168ff 100644
--- a/src/libs/utils/tasktree.h
+++ b/src/libs/utils/tasktree.h
@@ -45,6 +45,7 @@ private:
void activateStorage(int id);
struct StorageData {
+ ~StorageData();
StorageConstructor m_constructor = {};
StorageDestructor m_destructor = {};
QHash<int, void *> m_storageHash = {};