aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2021-04-23 14:57:06 +0200
committerChristian Stenger <christian.stenger@qt.io>2021-04-26 06:22:42 +0000
commit1effc866422b216632c65b43e373b56d0c247b80 (patch)
tree0b039242773498ac4db81019de26b468e2a4a80d
parent0e89a21c6d84516bea856981e298ee68834f661c (diff)
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>
-rw-r--r--src/plugins/autotest/testtreemodel.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp
index 9d5f3d6af08..3a5908e16f9 100644
--- a/src/plugins/autotest/testtreemodel.cpp
+++ b/src/plugins/autotest/testtreemodel.cpp
@@ -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());