Actions
Bug #3703
closedPaintedSlider::paintEvent Throws an Arithmetic Exception
Description
PaintedSlider::paintEvent will throw an Arithmetic Exception if range()
is 1. In the code below, it looks like there might be a logic error in the order of operations. It seems like there should be a check if range is 1 (which will result in a tickInterval
of zero) or numTicks
should be calculated as shown below to prevent an Arithmetic Exception.
void PaintedSlider::paintEvent(WPaintDevice *paintDevice)
{
int tickInterval = slider_->tickInterval();
int r = range();
if (tickInterval == 0)
tickInterval = r / 2;
int numTicks = r / tickInterval + 1;
if (numTicks < 1)
return;
int w = 0, h = 0;
switch (slider_->orientation()) {
case Horizontal:
w = (int)paintDevice->width().toPixels();
h = (int)paintDevice->height().toPixels();
break;
case Vertical:
w = (int)paintDevice->height().toPixels();
h = (int)paintDevice->width().toPixels();
}
numTicks
could be calculated like this:
int numTicks = r / (tickInterval + 1);
Updated by Wim Dumon almost 10 years ago
- Status changed from New to Resolved
This seems to be fixed already in the current git version:
int numTicks = tickInterval == 0 ? 2 : r / tickInterval + 1;
Updated by Koen Deforche over 9 years ago
- Status changed from Resolved to Closed
Actions