summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-09-25 18:02:54 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-09-26 08:49:14 +0000
commitcb029a36279a1b7d47ec4c58c7916c9b63615b57 (patch)
tree8ef21337a7b92154db973ccb1cee3df818c6d49b /src
parent1056eb37c970a7145755d0280f03d049d9a77bd5 (diff)
downloadqtquickcontrols-cb029a36279a1b7d47ec4c58c7916c9b63615b57.tar.gz
ScrollView: Defer calls to doLayout()
doLayout() updates the dimensions of the scroll view, and therefore can trigger the scroll bars to be shown or hidden. That, in turn, can trigger another call to doLayout(), resulting in binding loops. Avoid those by deferring the call. The scrollview tests are broken without this change because the binding loop prevents the scrollbars from being shown or hidden in some cases. The deferring necessitates a tryVerify(), but fixes the actual tests. Change-Id: I0dac0ba380240e025237f69c4d357d764a535c3d Fixes: QTBUG-50605 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/controls/Private/ScrollViewHelper.qml18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/controls/Private/ScrollViewHelper.qml b/src/controls/Private/ScrollViewHelper.qml
index 810de91d..53050108 100644
--- a/src/controls/Private/ScrollViewHelper.qml
+++ b/src/controls/Private/ScrollViewHelper.qml
@@ -68,31 +68,29 @@ Item {
anchors.fill: parent
- property bool recursionGuard: false
-
- function doLayout() {
- if (!recursionGuard) {
- recursionGuard = true
+ Timer {
+ id: layoutTimer
+ interval: 0;
+ onTriggered: {
blockUpdates = true;
scrollHelper.contentWidth = flickableItem !== null ? flickableItem.contentWidth : 0
scrollHelper.contentHeight = flickableItem !== null ? flickableItem.contentHeight : 0
scrollHelper.availableWidth = viewport.width
scrollHelper.availableHeight = viewport.height
blockUpdates = false;
- recursionGuard = false
}
}
Connections {
target: viewport
- onWidthChanged: doLayout()
- onHeightChanged: doLayout()
+ onWidthChanged: layoutTimer.running = true
+ onHeightChanged: layoutTimer.running = true
}
Connections {
target: flickableItem
- onContentWidthChanged: doLayout()
- onContentHeightChanged: doLayout()
+ onContentWidthChanged: layoutTimer.running = true
+ onContentHeightChanged: layoutTimer.running = true
onContentXChanged: {
hscrollbar.flash()
vscrollbar.flash()