Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003521 [JEDI VCL] 00 JVCL Components minor always 2006-02-19 14:52 2006-03-10 02:20
Reporter BThorson View Status public  
Assigned To AHUser
Priority normal Resolution fixed Platform
Status resolved   OS
Projection none   OS Version
ETA none Fixed in Version 3.30 Product Version 3.00
  Target Version Product Build
Summary 0003521: TJvSimIndicator Divide By Zero Error if Height is too small
Description When TJvSimIndicator height is less than 32, a Divide By zero Error is generated as it is being painted.

To reproduce, put the component on a form, set the height to any number less than 32 and run. A divide by zero error will be generated.

While the component is unusable at this size, if the user is not careful when
dynamically creating the component to avoid painting it when its size is too small, an error will be generated. In addition, it is unpleasant behavior and is
the result of an unnecessary floating point division anyway (see below.)
Steps To Reproduce
Additional Information Fix is straightforward. The Paint routine has an unecessary floating point divide that is generating the error.

The following code references are all in TJvSimIndicator.Paint.

The following line:
n := Round(h * (FValue - FMinimum)/(FMaximum - FMinimum) / dh);

can be replaced with:
n := Round(20 * (FValue - FMinimum)/(FMaximum - FMinimum));

This will fix the code.

Possibly better would be to replace the '20' with a constant since it is used
to generate the 'dh' value as well. So possible modification is:

const
 NUMBER_OF_BARS = 20;

then replace:
  dh := h div 20;
  n := Round(h * (FValue - FMinimum)/(FMaximum - FMinimum) / dh);

with
  dh := h div NUMBER_OF_BARS;
  n := Round(NUMBER_OF_BARS * (FValue - FMinimum)/(FMaximum - FMinimum));


Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0008641)
AHUser (developer)
2006-03-10 02:19

Fixed in CVS.

- Issue History
Date Modified Username Field Change
2006-02-19 14:52 BThorson New Issue
2006-03-10 02:19 AHUser Status new => resolved
2006-03-10 02:19 AHUser Resolution open => fixed
2006-03-10 02:19 AHUser Assigned To => AHUser
2006-03-10 02:19 AHUser Note Added: 0008641


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker