From 1effc866422b216632c65b43e373b56d0c247b80 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 23 Apr 2021 14:57:06 +0200 Subject: [PATCH] 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 --- src/plugins/autotest/testtreemodel.cpp | 2 ++ 1 file changed, 2 insertions(+) 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(itemForIndex(index(row, 0, parent)))) m_checkStateCache->insert(item, item->checked());