On 27-10-2010 14:32, Birger Jansen wrote:
Hi all,

I have the following code that throws an error in FPC and runs fine in Delphi:

procedure TForm1.BitBtn1Click(Sender: TObject);
var
   MyStringGrid: TStringGrid;
begin
   MyStringGrid := TStringGrid.Create(nil);
   try
     MyStringGrid.RowCount := 0;
     MyStringGrid.RowHeights[0] := 1;
   finally
     MyStringGrid.Free;
   end;
end;

Delphi checks if the grid has at least
In FPC there is no check on RowCount before the height is set, resulting in a 
List index(0) out of bounds exception. Although it is correct, it is annoying 
:-)

It can be fixed by adding something like this to the beginning of 
TCustomGrid.Setrowheights:

   if ARow<= FRows.Count then EXIT;

Shall I file a report for this?

Kind regards,
   Birger Jansen
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.864 / Virus Database: 271.1.1/3221 - Release Date: 10/26/10 
20:34:00

First: It is not a good idea to create the stringgrid without a parent... or any visual control. Annoying :) and potentionally dangereous. Second: As you remarked, the behaviour is correct. Why being annoyed about making a programming mistake?
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to