View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003521 | JEDI VCL | 00 JVCL Components | public | 2006-02-19 14:52 | 2006-03-10 02:20 |
Reporter | BThorson | Assigned To | AHUser | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 3.00 | ||||
Target Version | Fixed in Version | 3.30 | |||
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.) | ||||
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. | ||||