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
0003386 [JEDI VCL] 00 JVCL Components minor always 2005-12-26 09:34 2006-02-06 07:38
Reporter Lutz View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version 3.00
Summary 0003386: TJvStringGrid.LoadFromFile is loading only the first Row
Description Unit: JvStringGrid
TJvStringGrid.LoadFromFile is loading only the first Row.

Solution:
Row 770 to 813
procedure TJvStringGrid.LoadFromStream(Stream: TStream);

Replace var "Rom" by "Row", recompile the unit.
Additional Information
Tags No tags attached.
Attached Files

- Relationships

-  Notes
(0008346)
obones (administrator)
2006-01-08 12:08

Can you attach the zipped sources of a sample application showing the problem?
I don't understand why changing a variable name would fix the issue.
(0008354)
Lutz (reporter)
2006-01-08 17:27
edited on: 2006-01-08 17:29

Sure,you are right, the name of a variable doesn't matter much.
But please watch the following code. IMHO is it simply more logical to use everywhere "Row" instead of "Rom". But feel free to use "Rom", but if you do it, be consequent to use it everywhere.
The RowCount will not be increased if you use inconsequently and only here the name "Row".
This is the orignal code snippet from TJvStringGrid.pas with my explanation of the mistake:

================================================================

procedure TJvStringGrid.LoadFromStream(Stream: TStream);
var
  Col, Rom, I, Count: Integer;
  Buffer: array [0..BufSize - 1] of Byte;
  St: string;
begin
  Col := 0;
  Rom := 1;
  DoLoadProgress(0, Stream.Size);
  while Stream.Position < Stream.Size do
  begin
    Count := Stream.Read(Buffer, 1024);
    DoLoadProgress(Stream.Position, Stream.Size);
    for I := 0 to Count - 1 do
      case Buffer[I] of
        0:
          begin
            Inc(Col);
            if Rom > RowCount then
              RowCount := Rom;
            if Col > ColCount then
              ColCount := Col;
            Cells[Col - 1, Rom - 1] := St;
            St := '';
          end;
        1:
          begin
            Inc(Col);
            if Col > ColCount then
              ColCount := Col;
            Cells[Col - 1, Rom - 1] := St;
            Inc(Rom);
            if Rom > RowCount then
{ ==!!==> } RowCount := Row; { <== This is the inconsequence! }
            Col := 0;
            St := '';
          end;
      else
        St := St + Char(Buffer[I]);
      end;
  end;
  RowCount := RowCount - 1;
  DoLoadProgress(Stream.Size, Stream.Size);
end;
================================================================

Sorry if I did not attach an example but my application is simply to big for this small mistake. I am sure you can follow my idea without an example.

Impact:
The mistake was not the use of another name for the variable but the inconsequently use of it.
My beauty-feeling for self-explaining code still says: use the name "Row".

(0008511)
obones (administrator)
2006-02-06 07:38

Thanks, I did not notice. This is now fixed in CVS

- Issue History
Date Modified Username Field Change
2005-12-26 09:34 Lutz New Issue
2006-01-08 12:08 obones Note Added: 0008346
2006-01-08 12:08 obones Status new => feedback
2006-01-08 17:27 Lutz Note Added: 0008354
2006-01-08 17:29 Lutz Note Edited: 0008354
2006-01-08 17:29 Lutz Note Edited: 0008354
2006-02-06 07:38 obones Status feedback => resolved
2006-02-06 07:38 obones Resolution open => fixed
2006-02-06 07:38 obones Assigned To => obones
2006-02-06 07:38 obones Note Added: 0008511


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