From 6a56862a2214e4ff1743fc3ce97427a30475b48a Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 12 Feb 2020 15:13:57 +0100 Subject: 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 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qabstractitemview.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/widgets/itemviews/qabstractitemview.cpp') 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())); -- cgit v1.2.3