QListView: fix a broken qBound
If a QListView's model is reset to an empty one, its columnCount() below the root is going to be 0. Therefore, the code was doing a qBound(0, d->column, -1) which is meaningless (high < low). Instead, do the two logical operations explicitly: first do an upper bound on d->column (using qMin) and then lower bound the result by 0 (using qMax). The code worked by chance, because 0 was eventually the correct number to use as a bound for d->column. Change-Id: Ic32077cdab01eaa715137c05ed1f9d66c8eb2f67 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>bb10
parent
251e848007
commit
212b7614e1
|
|
@ -690,7 +690,7 @@ void QListView::reset()
|
|||
void QListView::setRootIndex(const QModelIndex &index)
|
||||
{
|
||||
Q_D(QListView);
|
||||
d->column = qBound(0, d->column, d->model->columnCount(index) - 1);
|
||||
d->column = qMax(0, qMin(d->column, d->model->columnCount(index) - 1));
|
||||
QAbstractItemView::setRootIndex(index);
|
||||
// sometimes we get an update before reset() is called
|
||||
d->clear();
|
||||
|
|
|
|||
Loading…
Reference in New Issue