Commit f0ae03ff authored by Jens Bache-Wiig's avatar Jens Bache-Wiig Committed by The Qt Project
Browse files

Fix recursion on max < min size for SpinBox


Change-Id: I24d80ee4c693e7e0bd1f7b3e8c12005a53425858
Reviewed-by: default avatarJ-P Nurmi <jpnurmi@digia.com>
parent 518b282e
No related merge requests found
Showing with 24 additions and 2 deletions
...@@ -90,7 +90,8 @@ FocusScope { ...@@ -90,7 +90,8 @@ FocusScope {
/*! /*!
The maximum value of the SpinBox range. The maximum value of the SpinBox range.
The \l value is clamped to this value. The \l value is clamped to this value. If maximumValue is smaller than
\l minimumValue, \l minimumValue will be enforced.
The default value is \c 99 The default value is \c 99
*/ */
...@@ -249,7 +250,8 @@ FocusScope { ...@@ -249,7 +250,8 @@ FocusScope {
var newval = parseFloat(v) var newval = parseFloat(v)
if (!isNaN(newval)) { if (!isNaN(newval)) {
if (newval > maximumValue) // we give minimumValue priority over maximum if they are inconsistent
if (newval > maximumValue && maximumValue >= minimumValue)
newval = maximumValue newval = maximumValue
else if (v < minimumValue) else if (v < minimumValue)
newval = minimumValue newval = minimumValue
......
...@@ -143,12 +143,32 @@ Item { ...@@ -143,12 +143,32 @@ Item {
var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '') var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '')
spinbox.value = spinbox.maximumValue + 1 spinbox.value = spinbox.maximumValue + 1
compare(spinbox.value, spinbox.maximumValue) compare(spinbox.value, spinbox.maximumValue)
spinbox.maximumValue = 0;
spinbox.minimumValue = 0;
spinbox.value = 10;
compare(spinbox.value, 0)
spinbox.maximumValue = 5;
spinbox.minimumValue = 0;
spinbox.value = 10;
compare(spinbox.value, 5)
} }
function test_minvalue() { function test_minvalue() {
var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '') var spinbox = Qt.createQmlObject('import QtDesktop 1.0; SpinBox {}', container, '')
spinbox.value = spinbox.minimumValue - 1 spinbox.value = spinbox.minimumValue - 1
compare(spinbox.value, spinbox.minimumValue) compare(spinbox.value, spinbox.minimumValue)
spinbox.maximumValue = 0;
spinbox.minimumValue = 6;
spinbox.value = 3;
compare(spinbox.value, 6)
spinbox.maximumValue = 10;
spinbox.minimumValue = 6;
spinbox.value = 0;
compare(spinbox.value, 6)
} }
function test_nanvalue() { function test_nanvalue() {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment