diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2021-04-23 12:16:26 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2021-04-23 16:15:11 +0200 |
commit | e7df2279bf5519703fd0b853abaa23947a599920 (patch) | |
tree | f90876be32c6dab43f0ccdf8bc5a44eb8a1c4903 /tests/auto | |
parent | 6259c4a8cca6581216f39a57e989191059e398bc (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
Pick-to: 6.1 6.0 5.15
Change-Id: I1470766c6de02b7b601edf1375791d3147f26ab5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/controls/data/tst_scrollview.qml | 24 |
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 d8c210a4..7404d0e6 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) + } } |