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 <eike.ziller@qt.io>
This commit is contained in:
Christian Stenger
2022-10-10 10:01:26 +02:00
parent bbf55a881a
commit 1462258939

View File

@@ -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