From 1462258939c4c98bf5d480a9cc1dfc70fbafa954 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 10 Oct 2022 10:01:26 +0200 Subject: [PATCH] AutoTest: Avoid crash Do not emit sizeHintChanged() on a QModelIndex that is no more part of the model. Fixes: QTCREATORBUG-28269 Change-Id: I1fa1733961eff8b427a9510243d304565cefe380 Reviewed-by: Eike Ziller --- src/plugins/autotest/testresultdelegate.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/autotest/testresultdelegate.cpp b/src/plugins/autotest/testresultdelegate.cpp index 9d123bbad86..161857ca9d8 100644 --- a/src/plugins/autotest/testresultdelegate.cpp +++ b/src/plugins/autotest/testresultdelegate.cpp @@ -181,8 +181,12 @@ void TestResultDelegate::clearCache() m_lastProcessedIndex = QModelIndex(); m_lastProcessedFont = QFont(); m_lastWidth = -1; - if (current.isValid()) - emit sizeHintChanged(current); + if (current.isValid()) { + if (auto model = current.model()) { + if (model->index(current.row(), current.column(), current.parent()) == current) + emit sizeHintChanged(current); + } + } } void TestResultDelegate::limitTextOutput(QString &output) const