1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-11 09:24:50 +01:00

Fix overflow in MoodbarProxyStyle (fixes #5638) (#5643)

This commit is contained in:
Santiago Gil 2017-03-02 10:10:21 -03:00 committed by John Maguire
parent 27bf50d702
commit 30e3fdb9cc

View File

@ -270,17 +270,20 @@ QRect MoodbarProxyStyle::subControlRect(ComplexControl cc,
case SC_SliderHandle: { case SC_SliderHandle: {
const QStyleOptionSlider* slider_opt = const QStyleOptionSlider* slider_opt =
qstyleoption_cast<const QStyleOptionSlider*>(opt); qstyleoption_cast<const QStyleOptionSlider*>(opt);
int x = 0; int x_offset = 0;
/* slider_opt->{maximum,minimum} can have the value 0 (their default /* slider_opt->{maximum,minimum} can have the value 0 (their default
values), so this check avoids a division by 0. */ values), so this check avoids a division by 0. */
if (slider_opt->maximum > slider_opt->minimum) { if (slider_opt->maximum > slider_opt->minimum) {
x = (slider_opt->sliderValue - slider_opt->minimum) * qint64 slider_delta = slider_opt->sliderValue - slider_opt->minimum;
(opt->rect.width() - kArrowWidth) / qint64 slider_range = slider_opt->maximum - slider_opt->minimum;
(slider_opt->maximum - slider_opt->minimum); int rectangle_effective_width = opt->rect.width() - kArrowWidth;
qint64 x = slider_delta * rectangle_effective_width / slider_range;
x_offset = static_cast<int>(x);
} }
return QRect(QPoint(opt->rect.left() + x, opt->rect.top()), return QRect(QPoint(opt->rect.left() + x_offset, opt->rect.top()),
QSize(kArrowWidth, kArrowHeight)); QSize(kArrowWidth, kArrowHeight));
} }