Actions
Bug #3703
closed
JL
WD
PaintedSlider::paintEvent Throws an Arithmetic Exception
Bug #3703:
PaintedSlider::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:
WD Updated by Wim Dumon over 11 years ago
KD Updated by Koen Deforche over 11 years ago
- Status changed from Resolved to Closed
Actions