forked from qt-creator/qt-creator
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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user