From 56b0d77c8276c8c3aa122409643deaaddb075bfb Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Sun, 30 Apr 2023 12:18:00 +0200 Subject: [PATCH] TaskTree: Add an useful warning message It's a common mistake to forget to insert the Storage element into the tree, but reuse it from inside running handlers. This message should help in quick fixing the issue. Change-Id: I771e89b06943667b56188d0655ec3da1b48f8a34 Reviewed-by: Marcus Tillmanns --- src/libs/utils/tasktree.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/utils/tasktree.cpp b/src/libs/utils/tasktree.cpp index 8ea51369322..97a4dbae66c 100644 --- a/src/libs/utils/tasktree.cpp +++ b/src/libs/utils/tasktree.cpp @@ -33,7 +33,12 @@ TreeStorageBase::StorageData::~StorageData() void *TreeStorageBase::activeStorageVoid() const { - QTC_ASSERT(m_storageData->m_activeStorage, return nullptr); + QTC_ASSERT(m_storageData->m_activeStorage, qWarning( + "The referenced storage is not reachable in the running tree. " + "A nullptr will be returned which might lead to a crash in the calling code. " + "It is possible that no storage was added to the tree, " + "or the storage is not reachable from where it is referenced."); + return nullptr); const auto it = m_storageData->m_storageHash.constFind(m_storageData->m_activeStorage); QTC_ASSERT(it != m_storageData->m_storageHash.constEnd(), return nullptr); return it.value();