From b52c86cf1b394da1ec1628e516f448d23008e8a3 Mon Sep 17 00:00:00 2001 From: davidsastresas Date: Thu, 1 Jul 2021 11:48:54 +0200 Subject: [PATCH] PhotoVideoControl.qml: fix Slider setting some facts to minimum: Sliders with a non 0 minimum value have this issue where the default minimum is 0, so if setting a new minimum value changes, and thus we have an onValueChanged, setting the value of the slider to minimum even before onCompleted, so if they need to be initialized to something it doesn't work. This commit fixes it setting a bool variable so onValueChanged doesn't take effect until initialized --- src/FlightMap/Widgets/PhotoVideoControl.qml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/FlightMap/Widgets/PhotoVideoControl.qml b/src/FlightMap/Widgets/PhotoVideoControl.qml index bf85f97..b1b50b9 100644 --- a/src/FlightMap/Widgets/PhotoVideoControl.qml +++ b/src/FlightMap/Widgets/PhotoVideoControl.qml @@ -467,8 +467,19 @@ Rectangle { stepSize: parent._fact.increment visible: parent._isSlider updateValueWhileDragging: false - onValueChanged: parent._fact.value = value - Component.onCompleted: value = parent._fact.value + property bool initialized: false + + onValueChanged: { + if (!initialized) { + return + } + parent._fact.value = value + } + + Component.onCompleted: { + value = parent._fact.value + initialized = true + } } QGCSwitch { checked: parent._fact ? parent._fact.value : false