summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
authorTang Haixiang <tanghaixiang@uniontech.com>2022-06-27 15:28:09 +0800
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-07-05 11:55:19 +0000
commit551127209e6c45fcbbd176a65ad425c47c9bc09c (patch)
tree481c9ec4863016864890e40fc987e87bd0e18aee /src/widgets/itemviews
parentc2a63b40140e09ad12bec54714302db5baad9d35 (diff)
QListview: PageDown/Up infinite loop
When item.height > viewport.height, the next item is not found correctly, resulting in an infinite loop. In this case, move directly to the next item. Pick-to: 6.4 6.3 6.2 Change-Id: I67a40a079ca9dd9189bf84ae550758c685b83d75 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qlistview.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index ce771911b3..7f8f7a20fe 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -1201,7 +1201,10 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
}
return d->closestIndex(initialRect, intersectVector);
case MovePageUp: {
- rect.moveTop(rect.top() - d->viewport->height() + 1 );
+ if (rect.height() >= d->viewport->height())
+ return moveCursor(QAbstractItemView::MoveUp, modifiers);
+
+ rect.moveTop(rect.top() - d->viewport->height() + 1);
if (rect.top() < rect.height()) {
rect.setTop(0);
rect.setBottom(1);
@@ -1242,8 +1245,11 @@ QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
}
return d->closestIndex(initialRect, intersectVector);
case MovePageDown: {
- rect.moveTop(rect.top() + d->viewport->height() - 1 );
- if (rect.bottom() > contents.height() - rect.height()){
+ if (rect.height() >= d->viewport->height())
+ return moveCursor(QAbstractItemView::MoveDown, modifiers);
+
+ rect.moveTop(rect.top() + d->viewport->height() - 1);
+ if (rect.bottom() > contents.height() - rect.height()) {
rect.setTop(contents.height() - 1);
rect.setBottom(contents.height());
}