View Issue Details

IDProjectCategoryView StatusLast Update
0024393LazarusLazReportpublic2014-03-10 00:08
ReporterSergey StepnoyAssigned ToJesus Reyes 
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.0.8Product Build 
Target Version1.4Fixed in Version1.1 (SVN) 
Summary0024393: Patch for LazReport - property "ZOOM" of the object "Barcode"
DescriptionThe functions of the GetSaveProperty (on line 11659):
tkFloat: begin
           OldSep := DecimalSeparator;
           DecimalSeparator := '.';
           Result := FloatToStr(GetFloatProp(aObj,Prop));
           DecimalSeparator := OldSep;
         end;
--> replaced:
tkFloat: begin
            s := FloatToStr(GetFloatProp(aObj,Prop));
            s := StringReplace(s, ThousandSeparator, '', [rfReplaceAll, rfIgnoreCase]);
            Result := StringReplace(s, DecimalSeparator, '.', [rfReplaceAll, rfIgnoreCase]);
         end;

and The functions of the RestoreProperty(on line 11703):
tkFloat : SetFloatProp(aObj,Prop,StrToFloat(aValue));
--> replaced:
tkFloat: begin
            s := StringReplace(aValue, '.', DecimalSeparator, [rfReplaceAll, rfIgnoreCase]);
            SetFloatProp(aObj,Prop,StrToFloat(s));
          end;
Tagslazreport
Fixed in Revision41070
LazTarget1.4
WidgetsetWin32/Win64
Attached Files
  • lr_class.pas.patch (2,322 bytes)
    Index: source/lr_class.pas
    ===================================================================
    --- source/lr_class.pas	(revision 41056)
    +++ source/lr_class.pas	(working copy)
    @@ -11635,6 +11635,7 @@
     Var PropInfo  : PPropInfo;
         Obj       : TObject;
         OldSep    : char;
    +    s         : String;
     begin
       Result:='';
     
    @@ -11657,10 +11658,9 @@
                                           end;
             tkSet                       : Result:=GetSetProp(aObj,Prop);
             tkFloat                     : begin
    -                                        OldSep := DecimalSeparator;
    -                                        DecimalSeparator := '.';
    -                                        Result := FloatToStr(GetFloatProp(aObj,Prop));
    -                                        DecimalSeparator := OldSep;
    +                                        s := FloatToStr(GetFloatProp(aObj,Prop));
    +                                        s := StringReplace(s, ThousandSeparator, '', [rfReplaceAll, rfIgnoreCase]);
    +                                        Result := StringReplace(s, DecimalSeparator, '.', [rfReplaceAll, rfIgnoreCase]);
                                           end;
             tkEnumeration               : Result:=GetEnumProp(aObj,Prop);
             tkClass                     : Begin
    @@ -11681,6 +11681,7 @@
     procedure TfrObject.RestoreProperty(const Prop, aValue: String;  aObj : TPersistent=nil);
     Var PropInfo  : PPropInfo;
         Obj       : TObject;
    +    s         : String;
     begin
       Try
         if not Assigned(aObj) then
    @@ -11700,7 +11701,10 @@
                                               SetOrdProp(aObj,PropInfo,StrToInt(aValue))
                                           end;
             tkSet                       : SetSetProp(aObj,Prop,aValue);
    -        tkFloat                     : SetFloatProp(aObj,Prop,StrToFloat(aValue));
    +        tkFloat                     : begin
    +                                           s := StringReplace(aValue, '.', DecimalSeparator, [rfReplaceAll, rfIgnoreCase]);
    +                                           SetFloatProp(aObj,Prop,StrToFloat(s));
    +                                      end;
             tkEnumeration               : SetEnumProp(aObj,Prop,aValue);
             tkClass                     : Begin
                                             Obj:=GetObjectProp(aObj,Prop);
    
    lr_class.pas.patch (2,322 bytes)

Activities

Sergey Stepnoy

2013-05-06 19:41

reporter   ~0067522

I'm sorry, but I have a bad English.

Juha Manninen

2013-05-06 19:58

developer   ~0067523

Create a proper patch please :
 http://wiki.freepascal.org/Creating_A_Patch

Sergey Stepnoy

2013-05-07 01:47

reporter  

lr_class.pas.patch (2,322 bytes)
Index: source/lr_class.pas
===================================================================
--- source/lr_class.pas	(revision 41056)
+++ source/lr_class.pas	(working copy)
@@ -11635,6 +11635,7 @@
 Var PropInfo  : PPropInfo;
     Obj       : TObject;
     OldSep    : char;
+    s         : String;
 begin
   Result:='';
 
@@ -11657,10 +11658,9 @@
                                       end;
         tkSet                       : Result:=GetSetProp(aObj,Prop);
         tkFloat                     : begin
-                                        OldSep := DecimalSeparator;
-                                        DecimalSeparator := '.';
-                                        Result := FloatToStr(GetFloatProp(aObj,Prop));
-                                        DecimalSeparator := OldSep;
+                                        s := FloatToStr(GetFloatProp(aObj,Prop));
+                                        s := StringReplace(s, ThousandSeparator, '', [rfReplaceAll, rfIgnoreCase]);
+                                        Result := StringReplace(s, DecimalSeparator, '.', [rfReplaceAll, rfIgnoreCase]);
                                       end;
         tkEnumeration               : Result:=GetEnumProp(aObj,Prop);
         tkClass                     : Begin
@@ -11681,6 +11681,7 @@
 procedure TfrObject.RestoreProperty(const Prop, aValue: String;  aObj : TPersistent=nil);
 Var PropInfo  : PPropInfo;
     Obj       : TObject;
+    s         : String;
 begin
   Try
     if not Assigned(aObj) then
@@ -11700,7 +11701,10 @@
                                           SetOrdProp(aObj,PropInfo,StrToInt(aValue))
                                       end;
         tkSet                       : SetSetProp(aObj,Prop,aValue);
-        tkFloat                     : SetFloatProp(aObj,Prop,StrToFloat(aValue));
+        tkFloat                     : begin
+                                           s := StringReplace(aValue, '.', DecimalSeparator, [rfReplaceAll, rfIgnoreCase]);
+                                           SetFloatProp(aObj,Prop,StrToFloat(s));
+                                      end;
         tkEnumeration               : SetEnumProp(aObj,Prop,aValue);
         tkClass                     : Begin
                                         Obj:=GetObjectProp(aObj,Prop);
lr_class.pas.patch (2,322 bytes)

Sergey Stepnoy

2013-05-07 03:51

reporter   ~0067531

Last edited: 2013-05-07 03:57

View 5 revisions

In the designer to add Barcode, do setup and install ZOOM property to "1,5" (the comma is used, also she stands in the regional setting), saves the report,
and when i open the report an error occurs "1.5 is an invalid float" by about line 11708 class LR_Class.

Jesus Reyes

2013-05-08 09:02

developer   ~0067561

LazReport should never store "thousand" separated values, but if you have a test case, please attach it here.

For the moment I fixed reading float values in xxxxxx.yy format, please test.

Sergey Stepnoy

2013-05-08 09:31

reporter   ~0067565

There is a the remark on the account of newly-added procedure (lrNormalizeLocaleFloats).
When operating a multi-threaded application has a probability of simultaneous access to "DefaultFormatSettings.DecimalSeparator", which can result in an error in the flow program.

Jesus Reyes

2013-05-08 19:20

developer   ~0067581

LazReport is not thread safe.

Please feel free to attach a test case that breaks by applying r41070 but works if fixed with your patch.

My guess is that FreeReport was not designed to be thread safe and so it is LazReport. A patch to make it thread safe is welcome, but lets first agree on the plan.

Jesus Reyes

2014-03-10 00:08

developer   ~0073576

No feedback

Issue History

Date Modified Username Field Change
2013-05-06 18:51 Sergey Stepnoy New Issue
2013-05-06 19:09 Sergey Stepnoy Tag Attached: lazreport
2013-05-06 19:41 Sergey Stepnoy Note Added: 0067522
2013-05-06 19:58 Juha Manninen Note Added: 0067523
2013-05-06 20:12 Jesus Reyes Assigned To => Jesus Reyes
2013-05-06 20:12 Jesus Reyes Status new => assigned
2013-05-07 01:47 Sergey Stepnoy File Added: lr_class.pas.patch
2013-05-07 03:51 Sergey Stepnoy Note Added: 0067531
2013-05-07 03:52 Sergey Stepnoy Note Edited: 0067531 View Revisions
2013-05-07 03:55 Sergey Stepnoy Note Edited: 0067531 View Revisions
2013-05-07 03:55 Sergey Stepnoy Note Edited: 0067531 View Revisions
2013-05-07 03:57 Sergey Stepnoy Note Edited: 0067531 View Revisions
2013-05-08 09:02 Jesus Reyes Fixed in Revision => 41070
2013-05-08 09:02 Jesus Reyes LazTarget => 1.2
2013-05-08 09:02 Jesus Reyes Note Added: 0067561
2013-05-08 09:02 Jesus Reyes Status assigned => resolved
2013-05-08 09:02 Jesus Reyes Fixed in Version => 1.1 (SVN)
2013-05-08 09:02 Jesus Reyes Resolution open => fixed
2013-05-08 09:02 Jesus Reyes Target Version => 1.2.0
2013-05-08 09:31 Sergey Stepnoy Note Added: 0067565
2013-05-08 11:03 Sergey Stepnoy Status resolved => assigned
2013-05-08 11:03 Sergey Stepnoy Resolution fixed => reopened
2013-05-08 19:20 Jesus Reyes Note Added: 0067581
2013-05-08 19:20 Jesus Reyes Status assigned => feedback
2014-02-17 16:31 Martin Friebe LazTarget 1.2 => 1.4
2014-02-17 16:32 Martin Friebe Target Version 1.2.0 => 1.4
2014-03-10 00:08 Jesus Reyes Note Added: 0073576
2014-03-10 00:08 Jesus Reyes Status feedback => closed
2014-03-10 00:08 Jesus Reyes Resolution reopened => fixed