Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004682 [JEDI VCL] 00 JVCL Components major always 2009-01-30 06:28 2009-07-08 14:57
Reporter cguser View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.36
Summary 0004682: TJvValidateEdit: Issues with DisplayFormat of dfFloat with DecimalPlaces
Description If DisplayFormat is set as dfFloat, and DecimalPlaces is 2, the following will happen:

JvValidateEdit1->AsFloat = 220.0;
double ValueInEdit = JvValidateEdit1->AsFloat;

ValueInEdit == 22000.0; // This evaluates to TRUE!!!

Seems that internal value is being *multiplied* by DecimalPlaces.
Additional Information
Tags No tags attached.
Attached Files 7z file icon Project1.7z [^] (3,177 bytes) 2009-02-02 10:02

- Relationships

-  Notes
(0015281)
obones (administrator)
2009-02-02 01:31

Please provide the zipped sources of a sample application showing this
(0015285)
cguser (reporter)
2009-02-02 10:01

Ok, there was a missing critical piece of information:
- DecimalSeparator is adjusted *after* component creation.


On TJvCustomValidateEdit::SetDisplayFormat,


procedure TJvCustomValidateEdit.SetDisplayFormat(NewValue: TJvValidateEditDisplayFormat);
(...)
    if (OldFormat in [..., dfFloat, ...]) and
      ... then
      SetAsFloat(JvSafeStrToFloatDef(FEditText, 0))



there is this call to JvSafeStrToFloatDef, which will call

GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, FormatSettings);

setting aDecimalSeparator as FormatSettings.DecimalSeparator

This will happen during component creation. The problem that I face comes from using a runtime VCL translator tool (Multilizer), that will reset local DecimalSeparator.

Therefore, the issue can be reproduced like this:

  DecimalSeparator = ','; // Let's say that Windows local system is set this way
  TJvValidateEdit *JvValidateEdit1 = new TJvValidateEdit(this);
  JvValidateEdit1->Parent = this;
  JvValidateEdit1->DisplayFormat = dfFloat;
  JvValidateEdit1->DecimalPlaces = 2;

  DecimalSeparator = '.';
  JvValidateEdit1->AsFloat = 220.0;
  // JvValidateEdit1->AsFloat is now equal to 22000.00


For now as a quick "fix", I'm reverting the code from
  SetAsFloat(JvSafeStrToFloatDef(FEditText, 0))
and
  Result := JvSafeStrToFloatDef(FEditText, 0);

into
  SetAsFloat(StrToFloatDef(FEditText, 0))
and
  Result := StrToFloatDef(FEditText, 0);

because setting an explicit ignore on the translator tool for TJvValidateEdit classes is not quite working as expected, yet...
(0015781)
obones (administrator)
2009-07-08 14:57

The problem, in the current version, was that CheckChars still contained the old value of DecimalSeparator.
I have introduced in SVN a new public method called RecalcCheckChars that allows to force rereading DecimalSeparator when it has changed.

- Issue History
Date Modified Username Field Change
2009-01-30 06:28 cguser New Issue
2009-02-02 01:28 obones Status new => acknowledged
2009-02-02 01:31 obones Note Added: 0015281
2009-02-02 01:31 obones Status acknowledged => feedback
2009-02-02 10:01 cguser Note Added: 0015285
2009-02-02 10:02 cguser File Added: Project1.7z
2009-07-06 14:04 obones Status feedback => acknowledged
2009-07-08 14:57 obones Note Added: 0015781
2009-07-08 14:57 obones Status acknowledged => resolved
2009-07-08 14:57 obones Fixed in Version => Daily / SVN
2009-07-08 14:57 obones Resolution open => fixed
2009-07-08 14:57 obones Assigned To => obones
2010-12-15 00:33 maoros Issue Monitored: maoros
2010-12-15 00:33 maoros Issue End Monitor: maoros


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