summaryrefslogtreecommitdiff
path: root/src/controls/CheckBox.qml
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2014-03-20 14:47:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-20 15:11:58 +0100
commit3adb18503a865e0bb826cb1b5be059572bb96594 (patch)
tree7a97e5f0d65392148d3350a8272660c25d4c1a5a /src/controls/CheckBox.qml
parent89f9aa0038b76a5e06cf2621bd588ce89f2c7189 (diff)
downloadqtquickcontrols-3adb18503a865e0bb826cb1b5be059572bb96594.tar.gz
Try to maintain bindings to checked property in CheckBox
It is currently impossible to keep a binding to the checked property because any external manipulation of checked will cause it to be internally overwritten based on the implicitly triggered checkedStateChanged signal. This adds a protection mechanism similar to what we already have on the checkedStateChanged signal. [ChangeLog][QtQuickControls][CheckBox]Fixed a problem incorrectly causing bindings to the checked state to break. Task-number: QTBUG-31627 Change-Id: I506fa34561529a414c7b088001f96e8f283edd89 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls/CheckBox.qml')
-rw-r--r--src/controls/CheckBox.qml14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/controls/CheckBox.qml b/src/controls/CheckBox.qml
index 00671755..e96e64fd 100644
--- a/src/controls/CheckBox.qml
+++ b/src/controls/CheckBox.qml
@@ -132,6 +132,13 @@ AbstractCheckable {
*/
property bool __ignoreChecked: false
+ /*!
+ \internal
+ True if onCheckedStateChanged should be ignored because we were reacting
+ to onCheckedChanged.
+ */
+ property bool __ignoreCheckedState: false
+
style: Qt.createComponent(Settings.style + "/CheckBoxStyle.qml", checkBox)
activeFocusOnTab: true
@@ -142,8 +149,11 @@ AbstractCheckable {
__cycleStatesHandler: __cycleCheckBoxStates
onCheckedChanged: {
- if (!__ignoreChecked)
+ if (!__ignoreChecked) {
+ __ignoreCheckedState = true;
checkedState = checked ? Qt.Checked : Qt.Unchecked;
+ __ignoreCheckedState = false;
+ }
}
onCheckedStateChanged: {
@@ -151,7 +161,7 @@ AbstractCheckable {
if (checkedState === Qt.PartiallyChecked) {
partiallyCheckedEnabled = true;
checked = false;
- } else {
+ } else if (!__ignoreCheckedState) {
checked = checkedState === Qt.Checked;
}
__ignoreChecked = false;