AutoTest: Fix crash on closing a project

If the check state of a tree item changes due to closing
the project and there is no other project open we access
a nullptr.

Change-Id: Ib08031e19eaae0837d1dc0485a05756cd8d0c0dc
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2021-04-23 14:57:06 +02:00
parent 0e89a21c6d
commit 1effc86642

View File

@@ -685,6 +685,8 @@ void Autotest::TestTreeModel::onDataChanged(const QModelIndex &topLeft,
if (!roles.isEmpty() && !roles.contains(Qt::CheckStateRole))
return;
if (!m_checkStateCache) // dataChanged() may be triggered by closing a project
return;
for (int row = topLeft.row(), endRow = bottomRight.row(); row <= endRow; ++row) {
if (auto item = static_cast<ITestTreeItem *>(itemForIndex(index(row, 0, parent))))
m_checkStateCache->insert(item, item->checked());