Project

General

Profile

Actions

Bug #3703

closed

PaintedSlider::paintEvent Throws an Arithmetic Exception

Added by Josh Lampco about 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
12/16/2014
Due date:
% Done:

0%

Estimated time:

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);
Actions #1

Updated by Wim Dumon about 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;
Actions #2

Updated by Koen Deforche almost 10 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF