diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-01-07 12:50:14 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@theqtcompany.com> | 2015-01-19 08:21:01 +0100 |
commit | cd389e4584754554282fbcb1cdc1b174d0f211dc (patch) | |
tree | ff5f4090952f199ef22ecf387d2229b60d1774ad | |
parent | 49fd3511f5bcdd61c92894636fcf0b2be23d1264 (diff) |
Fix possible divide by zero in QMacStyle
[ChangeLog][Widgets][QMacStyle] Fixed a possible divide by zero crash.
Task-number: QTBUG-43398
Change-Id: I8b5c6fd87d07eb42ad43e8c2405b7cad19372b86
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index c166b1b26e..38c082baf5 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1675,13 +1675,14 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti else tdi->max = 10 * slider->rect.height(); - if (usePlainKnob || slider->orientation == Qt::Horizontal) { + int range = slider->maximum - slider->minimum; + if (range == 0) { + tdi->value = 0; + } else if (usePlainKnob || slider->orientation == Qt::Horizontal) { int endsCorrection = usePlainKnob ? 25 : 10; - tdi->value = (tdi->max + 2 * endsCorrection) * (slider->sliderPosition - slider->minimum) - / (slider->maximum - slider->minimum) - endsCorrection; + tdi->value = (tdi->max + 2 * endsCorrection) * (slider->sliderPosition - slider->minimum) / range - endsCorrection; } else { - tdi->value = (tdi->max + 30) * (slider->sliderPosition - slider->minimum) - / (slider->maximum - slider->minimum) - 20; + tdi->value = (tdi->max + 30) * (slider->sliderPosition - slider->minimum) / range - 20; } } tdi->attributes = kThemeTrackShowThumb; |