Fix segfault in QItemSelectionModel::hasSelection
Amends 0c2125458a.
The code assumed that a QItemSelectionModel always has a model.
But during initialization from QML, it hasn't.
Fixes: QTBUG-97475
Pick-to: 6.2 6.2.1
Change-Id: Ie9c680f8989a23ef732faaf5da7ef7ae273126aa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
bb10
parent
f08704330d
commit
dbc434dc09
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue