* D2009 compat: TStringList.OwnsObjects

git-svn-id: trunk@16058 -
This commit is contained in:
marco 2010-09-28 14:52:44 +00:00
parent 19e037dde7
commit 6ebda8f2cc
2 changed files with 20 additions and 6 deletions

View File

@ -666,6 +666,7 @@ type
FDuplicates: TDuplicates;
FCaseSensitive : Boolean;
FSorted: Boolean;
FOwnsObjects : Boolean;
procedure ExchangeItems(Index1, Index2: Integer);
procedure Grow;
procedure QuickSort(L, R: Integer; CompareFn: TStringListSortCompare);
@ -702,6 +703,7 @@ type
property CaseSensitive: Boolean read FCaseSensitive write SetCaseSensitive;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
property OwnsObjects : boolean read FOwnsObjects write FOwnsObjects;
end;
{$else}
@ -717,6 +719,7 @@ type
FOnChange: TNotifyEvent;
FOnChanging: TNotifyEvent;
FOnCompareText: TStringListTextCompare;
FOwnsObjects : Boolean;
procedure SetCaseSensitive(NewSensitive: Boolean);
protected
procedure Changed; virtual;
@ -755,6 +758,7 @@ type
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
property OnCompareText: TStringListTextCompare read FOnCompareText write FOnCompareText;
property OwnsObjects : boolean read FOwnsObjects write FOwnsObjects;
end;
{$endif}

View File

@ -1156,8 +1156,6 @@ begin
InsertItem (Result,S);
end;
Procedure TStringList.Clear;
Var I : longint;
@ -1165,15 +1163,24 @@ Var I : longint;
begin
if FCount = 0 then Exit;
Changing;
For I:=0 to FCount-1 do
Flist^[I].FString:='';
if FOwnsObjects then
begin
For I:=0 to FCount-1 do
begin
Flist^[I].FString:='';
freeandnil(Flist^[i].FObject);
end;
end
else
begin
For I:=0 to FCount-1 do
Flist^[I].FString:='';
end;
FCount:=0;
SetCapacity(0);
Changed;
end;
Procedure TStringList.Delete(Index: Integer);
begin
@ -1181,6 +1188,8 @@ begin
Error(SlistINdexError,Index);
Changing;
Flist^[Index].FString:='';
if FOwnsObjects then
FreeAndNil(Flist^[Index].FObject);
Dec(FCount);
If Index<FCount then
System.Move(Flist^[Index+1],
@ -1316,6 +1325,7 @@ end;
constructor TStringList.Create;
begin
inherited;
FOwnsObjects:=false;
FMap := TFPStrObjMap.Create;
FMap.OnPtrCompare := @MapPtrCompare;
FOnCompareText := @DefaultCompareText;