forked from qt-creator/qt-creator
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 <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -33,7 +33,12 @@ TreeStorageBase::StorageData::~StorageData()
|
|||||||
|
|
||||||
void *TreeStorageBase::activeStorageVoid() const
|
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);
|
const auto it = m_storageData->m_storageHash.constFind(m_storageData->m_activeStorage);
|
||||||
QTC_ASSERT(it != m_storageData->m_storageHash.constEnd(), return nullptr);
|
QTC_ASSERT(it != m_storageData->m_storageHash.constEnd(), return nullptr);
|
||||||
return it.value();
|
return it.value();
|
||||||
|
Reference in New Issue
Block a user