<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 27-10-2010 14:32, Birger Jansen wrote:
<blockquote
cite="mid:vmime.4cc81bf6.1283.743b82f6ef115a9@cnoc-1a.cnoc.intern"
type="cite">
<pre wrap="">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 - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/mailman/listinfo/fpc-devel">http://lists.freepascal.org/mailman/listinfo/fpc-devel</a></pre>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
No virus found in this incoming message.
Checked by AVG - <a class="moz-txt-link-abbreviated" href="http://www.avg.com">www.avg.com</a>
Version: 9.0.864 / Virus Database: 271.1.1/3221 - Release Date: 10/26/10 20:34:00
</pre>
</blockquote>
First: It is not a good idea to create the stringgrid without a
parent... or any visual control. Annoying :) and potentionally
dangereous.<br>
Second: As you remarked, the behaviour is correct. Why being annoyed
about making a programming mistake?<br>
</body>
</html>