From 52c66e85156eb0547777ada07fe67e5e5ef653da Mon Sep 17 00:00:00 2001 From: "Raschbauer, Reinhard" Date: Wed, 17 May 2017 11:03:02 +0200 Subject: QAbstractItemView: fix nullptr violation If in a slot connected to QAbstractItemView::clicked QAbstractItemView::setModel(nullptr) is called the method QAbstractItemView::mouseReleaseEvent will cause a segmentation fault. The problem is that the method QAbstractItemView::model used in QAbstractItemView::mouseReleaseEvent will return a nullptr if a null model was set. The solution is to used d->model since it is always a valid model. (See line d->model = (model ? model : QAbstractItemModelPrivate::staticEmptyModel()); in method QAbstractItemView::setModel) Change-Id: I6f01bdeac64495ee4a76adcc7bf8da8a7719ef4d Reviewed-by: David Faure --- src/widgets/itemviews/qabstractitemview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index f056b7e5e5..25587a281d 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1925,7 +1925,7 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event) QStyleOptionViewItem option = d->viewOptionsV1(); if (d->pressedAlreadySelected) option.state |= QStyle::State_Selected; - if ((model()->flags(index) & Qt::ItemIsEnabled) + if ((d->model->flags(index) & Qt::ItemIsEnabled) && style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, &option, this)) emit activated(index); } -- cgit v1.2.3