AutoTest: Prevent potential nullptr access

Change-Id: I78eb4a5113d23273e9383c86fdefcffea05e0123
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Christian Stenger
2021-08-06 14:12:17 +02:00
parent 4652ef286b
commit fec3ef202f

View File

@@ -732,6 +732,8 @@ void TestTreeModel::handleParseResult(const TestParseResult *result, TestTreeIte
// restore former check state and fail state if available // restore former check state and fail state if available
newItem->forAllChildItems([this](TestTreeItem *childItem) { newItem->forAllChildItems([this](TestTreeItem *childItem) {
if (!m_checkStateCache) // parse results may arrive after session switch / project close
return;
Utils::optional<Qt::CheckState> cached = m_checkStateCache->get(childItem); Utils::optional<Qt::CheckState> cached = m_checkStateCache->get(childItem);
if (cached.has_value()) if (cached.has_value())
childItem->setData(0, cached.value(), Qt::CheckStateRole); childItem->setData(0, cached.value(), Qt::CheckStateRole);