QAbstractItemView: do not request illegal model indexes
If a model is empty, there is no index (0, 0); requesting it is undefined behavior. Rather than protecting the calls with checks on rowCount/columnCount, remove the Q_ASSERTs altogether: they're trying to do some basic sanity checks on the model, something that doesn't belong to a view (but, say, to QAbstractItemModelTester). Change-Id: I0ea25604fdcf524a10f5922a03a4d0700447f6a7 Reviewed-by: Andre Somers <andre.somers@kdab.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
115e39f9be
commit
6a56862a22
|
|
@ -705,15 +705,6 @@ void QAbstractItemView::setModel(QAbstractItemModel *model)
|
|||
}
|
||||
d->model = (model ? model : QAbstractItemModelPrivate::staticEmptyModel());
|
||||
|
||||
// These asserts do basic sanity checking of the model
|
||||
Q_ASSERT_X(d->model->index(0,0) == d->model->index(0,0),
|
||||
"QAbstractItemView::setModel",
|
||||
"A model should return the exact same index "
|
||||
"(including its internal id/pointer) when asked for it twice in a row.");
|
||||
Q_ASSERT_X(!d->model->index(0,0).parent().isValid(),
|
||||
"QAbstractItemView::setModel",
|
||||
"The parent of a top level index should be invalid");
|
||||
|
||||
if (d->model != QAbstractItemModelPrivate::staticEmptyModel()) {
|
||||
connect(d->model, SIGNAL(destroyed()),
|
||||
this, SLOT(_q_modelDestroyed()));
|
||||
|
|
|
|||
Loading…
Reference in New Issue