aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2023-01-23 23:51:55 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2023-01-25 14:05:31 +0000
commitb59bc4fe935245029a96d09a7dd55b53968fcc32 (patch)
tree87a5a8102443cca357895f75a4db49847f3946a8 /src
parentde480dd213815cf77f5da8a1f19365a1092d7c1a (diff)
Fix crash in ListView with PullBackHeader/Footer
The header/footer positioning code would otherwise call qBound() with max < min when a PullBackHeader/Footer is used and the delegates do not fill the whole content area (i.e. the list does not need scrolling). After qtbase ad5c5bb541ae20a205ac07122153b302dee1d3e1 that was causing an assertion failure. Even though relying on the old qBound() behavior seems strange, it does produce the correct header/footer positioning, while swapping the min/max values (in case max < min) does not. So we need to call qMin and qMax explicitly rather than using qBound, to avoid the assert. Task-number: QTBUG-104679 Pick-to: 6.4 6.5 Change-Id: Iefc50e347e77ed51c6d90ddbc6e1cf21d76fc62c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquicklistview.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 30b5ceb478..7693c9d288 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -1443,7 +1443,9 @@ void QQuickListViewPrivate::updateFooter()
} else if (visibleItems.size()) {
if (footerPositioning == QQuickListView::PullBackFooter) {
qreal viewPos = isContentFlowReversed() ? -position() : position() + size();
- qreal clampedPos = qBound(originPosition() - footerSize() + size(), listItem->position(), lastPosition());
+ // using qBound() would throw an assert here, because max < min is a valid case
+ // here, if the list's delegates do not fill the whole view
+ qreal clampedPos = qMax(originPosition() - footerSize() + size(), qMin(listItem->position(), lastPosition()));
listItem->setPosition(qBound(viewPos - footerSize(), clampedPos, viewPos));
} else {
qreal endPos = lastPosition();
@@ -1512,7 +1514,9 @@ void QQuickListViewPrivate::updateHeader()
// Make sure the header is not shown if we absolutely do not have any plans to show it
if (fixingUp && !headerNeedsSeparateFixup)
headerPosition = viewPos - headerSize();
- qreal clampedPos = qBound(originPosition() - headerSize(), headerPosition, lastPosition() - size());
+ // using qBound() would throw an assert here, because max < min is a valid case
+ // here, if the list's delegates do not fill the whole view
+ qreal clampedPos = qMax(originPosition() - headerSize(), qMin(headerPosition, lastPosition() - size()));
listItem->setPosition(qBound(viewPos - headerSize(), clampedPos, viewPos));
} else {
qreal startPos = originPosition();