diff options
author | Raschbauer, Reinhard <reinhard.raschbauer@bbv.ch> | 2017-05-17 11:03:02 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-08-04 08:36:29 +0000 |
commit | 52c66e85156eb0547777ada07fe67e5e5ef653da (patch) | |
tree | a18415541a9687ad884c6a55a3e19265bab59ffd /src/widgets | |
parent | 5169d588a599036aa1962f518a7c321f5e3e7296 (diff) |
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 <david.faure@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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); } |