diff --git a/src/libs/utils/historycompleter.cpp b/src/libs/utils/historycompleter.cpp index 8657374f776..fa037ddd612 100644 --- a/src/libs/utils/historycompleter.cpp +++ b/src/libs/utils/historycompleter.cpp @@ -117,8 +117,11 @@ private: if (layoutDirection() == Qt::LeftToRight) rr = viewport()->width() - event->x(); if (rr < clearButtonSize.width()) { - model->removeRow(indexAt(event->pos()).row()); - return; + const QModelIndex index = indexAt(event->pos()); + if (index.isValid()) { + model->removeRow(indexAt(event->pos()).row()); + return; + } } } QListView::mousePressEvent(event);