diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-02-12 15:13:57 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-02-14 15:13:39 +0100 |
commit | 6a56862a2214e4ff1743fc3ce97427a30475b48a (patch) | |
tree | 17268e32984c74650bd543d3880c53b7e4edb238 /src/widgets | |
parent | 115e39f9be99069dcb96579064e78b9a8f5468fc (diff) |
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>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index b07faf8be4..c3f8dd894e 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -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())); |