fixed mem leak and Index in TSynEditStringList.DeleteLines

git-svn-id: trunk@7400 -
This commit is contained in:
mattias 2005-07-22 15:36:47 +00:00
parent 653f20404a
commit 4e17e99aa8
2 changed files with 10 additions and 4 deletions

View File

@ -4897,7 +4897,7 @@ var
Copy(Lines[BE.Y - 1], BE.X, MaxInt);
// Delete all lines in the selection range.
{begin} // djlp 2000-09-13
TSynEditStringList(Lines).DeleteLines(BB.Y, BE.Y - BB.Y);
TSynEditStringList(Lines).DeleteLines(BB.Y-1, BE.Y - BB.Y);
// for x := BE.Y - 1 downto BB.Y do
// Lines.Delete(x);
{end} // djlp 2000-09-13

View File

@ -577,20 +577,26 @@ var
{$ENDIF}
begin
if NumLines > 0 then begin
if (Index < 0) or (Index > fCount) then
if (Index < 0) or (Index >= fCount) then
ListIndexOutOfBounds(Index);
LinesAfter := fCount - (Index + NumLines - 1);
LinesAfter := fCount - (Index + NumLines);
if LinesAfter < 0 then
NumLines := fCount - Index - 1;
NumLines := fCount - Index;
{$IFDEF FPC}
// free the strings
for i:=Index to Index+NumLines-1 do
fList^[i].fString:='';
{$ENDIF}
if LinesAfter > 0 then begin
BeginUpdate;
try
// move
System.Move(fList^[Index + NumLines], fList^[Index],
LinesAfter * SynEditStringRecSize);
{$IFDEF FPC}
// clear unused references
FillChar(fList^[Index + LinesAfter], NumLines * SynEditStringRecSize,0);
{$ENDIF}
finally
EndUpdate;
end;