summaryrefslogtreecommitdiff
path: root/dev-qt/qtquickcontrols/files/qtquickcontrols-5.12.1-scrollviewstyle-div-by-zero.patch
blob: b58f26ac53ce8fe70575c1545fe03ad37c7d51b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From c231395eec3494619f4977b4c5cd845b9d7341ae Mon Sep 17 00:00:00 2001
From: Benjamin Robin <dev@benjarobin.fr>
Date: Sun, 24 Feb 2019 10:28:14 +0100
Subject: [PATCH] ScrollViewStyle: Avoid division by zero in extent computation

If the flickableItem content is empty (contentWidth / contentHeight is
equal to 0), prevent the division by zero in the computation of the
extent variable.

Task-number: QTBUG-73691
Change-Id: I86becca9a1fa2508d1acafe09f46dfc952e4e96d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
---
 src/controls/Styles/Base/ScrollViewStyle.qml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/controls/Styles/Base/ScrollViewStyle.qml b/src/controls/Styles/Base/ScrollViewStyle.qml
index 6750399d4..36b518d39 100644
--- a/src/controls/Styles/Base/ScrollViewStyle.qml
+++ b/src/controls/Styles/Base/ScrollViewStyle.qml
@@ -370,8 +370,8 @@ Style {
 
         property var flickableItem: control.flickableItem
         property int extent: Math.max(minimumHandleLength, __styleData.horizontal ?
-                                          Math.min(1, (flickableItem ? flickableItem.width/flickableItem.contentWidth : 1)) * bg.width :
-                                          Math.min(1, (flickableItem ? flickableItem.height/flickableItem.contentHeight : 1)) * bg.height)
+                                          Math.min(1, ((flickableItem && flickableItem.contentWidth > 0.0) ? flickableItem.width/flickableItem.contentWidth : 1)) * bg.width :
+                                          Math.min(1, ((flickableItem && flickableItem.contentHeight > 0.0) ? flickableItem.height/flickableItem.contentHeight : 1)) * bg.height)
         readonly property real range: __control.maximumValue - __control.minimumValue
         readonly property real begin: __control.value - __control.minimumValue
 
-- 
2.16.3