From d01891cb30b12a9531caad6b82964bbd4cc330e2 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 24 Sep 2009 15:18:35 +0200 Subject: 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 --- src/gui/styles/qcleanlooksstyle.cpp | 14 +++++++------- 1 file 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; -- cgit v0.12