View Issue Details

IDProjectCategoryView StatusLast Update
0003521JEDI VCL00 JVCL Componentspublic2006-03-10 02:20
ReporterBThorsonAssigned ToAHUser 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.00 
Target VersionFixed in Version3.30 
Summary0003521: TJvSimIndicator Divide By Zero Error if Height is too small
DescriptionWhen 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.)
Additional InformationFix 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));


TagsNo tags attached.

Activities

AHUser

2006-03-10 02:19

developer   ~0008641

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