diff options
author | Andy Shaw <andy.shaw@nokia.com> | 2009-09-24 13:18:35 (GMT) |
---|---|---|
committer | Andy Shaw <andy.shaw@nokia.com> | 2009-09-24 13:18:35 (GMT) |
commit | d01891cb30b12a9531caad6b82964bbd4cc330e2 (patch) | |
tree | 96d454ce4c755fe62ecf40b7d14541941a7061c1 /src/gui/styles | |
parent | 240f69a0b26601fe34fe2a692ab50e5d738f02f9 (diff) | |
download | Qt-d01891cb30b12a9531caad6b82964bbd4cc330e2.zip Qt-d01891cb30b12a9531caad6b82964bbd4cc330e2.tar.gz Qt-d01891cb30b12a9531caad6b82964bbd4cc330e2.tar.bz2 |
Ensure that the gradient is not given an invalid stop point
When the size is 4 or less then it had would end up specifying a stop
point greater than 1 when setting up the gradient. By rights a size
less than 4 should not happen but this ensures it does not cause a
warning.
Reviewed-by: Jens Bache-Wiig
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qcleanlooksstyle.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 8647c90..fabd7ca 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -517,13 +517,13 @@ static void qt_cleanlooks_draw_buttongradient(QPainter *painter, const QRect &re gradient->setStops(bgBrush.gradient()->stops()); else { int size = horizontal ? rect.width() : rect.height() ; - if (size < 1) - size = 1; - float edge = 4.0/(float)size; - gradient->setColorAt(0, gradientStart); - gradient->setColorAt(edge, gradientMid.lighter(104)); - gradient->setColorAt(1.0 - edge, gradientMid.darker(100)); - gradient->setColorAt(1.0, gradientStop); + if (size > 4) { + float edge = 4.0/(float)size; + gradient->setColorAt(0, gradientStart); + gradient->setColorAt(edge, gradientMid.lighter(104)); + gradient->setColorAt(1.0 - edge, gradientMid.darker(100)); + gradient->setColorAt(1.0, gradientStop); + } } painter->fillRect(rect, *gradient); delete gradient; |