summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/itemmodels/qitemselectionmodel.cpp b/src/corelib/itemmodels/qitemselectionmodel.cpp
index ad24b5c9d8..6e1fbabd9d 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.cpp
+++ b/src/corelib/itemmodels/qitemselectionmodel.cpp
@@ -1738,8 +1738,11 @@ bool QItemSelectionModel::hasSelection() const
// d->ranges here. It sorts itself in executePendingOperations,
// thus preventing the sort to happen inside of selectionIsEmpty below.
// Sad story, read more in QTBUG-94546
- auto model_p = static_cast<const QAbstractItemModelPrivate *>(QObjectPrivate::get(model()));
- model_p->executePendingOperations();
+ const QAbstractItemModel *model = QItemSelectionModel::model();
+ if (model != nullptr) {
+ auto model_p = static_cast<const QAbstractItemModelPrivate *>(QObjectPrivate::get(model));
+ model_p->executePendingOperations();
+ }
if (d->currentCommand & (Toggle | Deselect)) {
QItemSelection sel = d->ranges;