QmlProfiler: Don't assert on data from invalid model index

When selecting an item that has no equivalent in the statistics view, we
should just clear the statistics view's selection.

Fixes: QTCREATORBUG-22262
Change-Id: Id43a46859ab33285fdfb1beafe7137e1bbb3b362
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Ulf Hermann
2019-04-09 11:06:51 +02:00
parent 810a39c706
commit 5e7818c48c

View File

@@ -298,13 +298,15 @@ void QmlProfilerStatisticsMainView::displayTypeIndex(int typeIndex)
QAbstractItemModel *sourceModel = sortModel->sourceModel();
QTC_ASSERT(sourceModel, return);
QModelIndex sourceIndex = sourceModel->index(qMin(typeIndex, sourceModel->rowCount() - 1),
MainCallCount);
QTC_ASSERT(sourceIndex.data(TypeIdRole).toInt() == typeIndex, return);
setCurrentIndex(sourceIndex.data(SortRole).toInt() > 0
? sortModel->mapFromSource(sourceIndex)
: QModelIndex());
if (typeIndex < sourceModel->rowCount()) {
QModelIndex sourceIndex = sourceModel->index(typeIndex, MainCallCount);
QTC_ASSERT(sourceIndex.data(TypeIdRole).toInt() == typeIndex, return);
setCurrentIndex(sourceIndex.data(SortRole).toInt() > 0
? sortModel->mapFromSource(sourceIndex)
: QModelIndex());
} else {
setCurrentIndex(QModelIndex());
}
}
// show in callers/callees subwindow