aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2021-04-23 12:16:26 +0200
committerMitch Curtis <mitch.curtis@qt.io>2021-04-26 11:46:09 +0200
commit16d946701d7fc38fce264ffdb4d5443ffcb50514 (patch)
tree98e663f754bf2cd76fd4c1f2580a59d2b1e8d517 /tests
parent470abc3566ead79a5c0b14b3dea4b40418cc1029 (diff)
ScrollView: fix crash when scrolling with zero-sized item
Check if a Flickable type was actually set as the contentItem before accessing the pointer. Also warn that using a type other than Flickable is not supported. Fixes: QTBUG-93039 Change-Id: I1470766c6de02b7b601edf1375791d3147f26ab5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit e7df2279bf5519703fd0b853abaa23947a599920)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/controls/data/tst_scrollview.qml24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml
index 87c39509..453f7753 100644
--- a/tests/auto/controls/data/tst_scrollview.qml
+++ b/tests/auto/controls/data/tst_scrollview.qml
@@ -502,4 +502,28 @@ TestCase {
compare(control.contentWidth, flickable.contentWidth)
compare(control.contentHeight, flickable.contentHeight)
}
+
+ Component {
+ id: zeroSizedContentItemComponent
+ ScrollView {
+ width: 100
+ height: 100
+ contentItem: Item {}
+ }
+ }
+
+ function test_zeroSizedContentItem() {
+ ignoreWarning(/ScrollView only supports Flickable types as its contentItem/)
+ let control = createTemporaryObject(zeroSizedContentItemComponent, testCase)
+ verify(control)
+
+ let verticalScrollBar = control.ScrollBar.vertical
+ verify(verticalScrollBar)
+ // Scrolling a ScrollView with a zero-sized contentItem shouldn't crash.
+ mouseDrag(verticalScrollBar, verticalScrollBar.width / 2, verticalScrollBar.height / 2, 0, 50)
+
+ let horizontalScrollBar = control.ScrollBar.horizontal
+ verify(verticalScrollBar)
+ mouseDrag(horizontalScrollBar, horizontalScrollBar.width / 2, horizontalScrollBar.height / 2, 50, 0)
+ }
}