mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 03:46:10 +02:00
* D2009 compat: TStringList.OwnsObjects
git-svn-id: trunk@16058 -
This commit is contained in:
parent
19e037dde7
commit
6ebda8f2cc
@ -666,6 +666,7 @@ type
|
|||||||
FDuplicates: TDuplicates;
|
FDuplicates: TDuplicates;
|
||||||
FCaseSensitive : Boolean;
|
FCaseSensitive : Boolean;
|
||||||
FSorted: Boolean;
|
FSorted: Boolean;
|
||||||
|
FOwnsObjects : Boolean;
|
||||||
procedure ExchangeItems(Index1, Index2: Integer);
|
procedure ExchangeItems(Index1, Index2: Integer);
|
||||||
procedure Grow;
|
procedure Grow;
|
||||||
procedure QuickSort(L, R: Integer; CompareFn: TStringListSortCompare);
|
procedure QuickSort(L, R: Integer; CompareFn: TStringListSortCompare);
|
||||||
@ -702,6 +703,7 @@ type
|
|||||||
property CaseSensitive: Boolean read FCaseSensitive write SetCaseSensitive;
|
property CaseSensitive: Boolean read FCaseSensitive write SetCaseSensitive;
|
||||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||||
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
|
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
|
||||||
|
property OwnsObjects : boolean read FOwnsObjects write FOwnsObjects;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$else}
|
{$else}
|
||||||
@ -717,6 +719,7 @@ type
|
|||||||
FOnChange: TNotifyEvent;
|
FOnChange: TNotifyEvent;
|
||||||
FOnChanging: TNotifyEvent;
|
FOnChanging: TNotifyEvent;
|
||||||
FOnCompareText: TStringListTextCompare;
|
FOnCompareText: TStringListTextCompare;
|
||||||
|
FOwnsObjects : Boolean;
|
||||||
procedure SetCaseSensitive(NewSensitive: Boolean);
|
procedure SetCaseSensitive(NewSensitive: Boolean);
|
||||||
protected
|
protected
|
||||||
procedure Changed; virtual;
|
procedure Changed; virtual;
|
||||||
@ -755,6 +758,7 @@ type
|
|||||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||||
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
|
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
|
||||||
property OnCompareText: TStringListTextCompare read FOnCompareText write FOnCompareText;
|
property OnCompareText: TStringListTextCompare read FOnCompareText write FOnCompareText;
|
||||||
|
property OwnsObjects : boolean read FOwnsObjects write FOwnsObjects;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$endif}
|
{$endif}
|
||||||
|
@ -1156,8 +1156,6 @@ begin
|
|||||||
InsertItem (Result,S);
|
InsertItem (Result,S);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Procedure TStringList.Clear;
|
Procedure TStringList.Clear;
|
||||||
|
|
||||||
Var I : longint;
|
Var I : longint;
|
||||||
@ -1165,15 +1163,24 @@ Var I : longint;
|
|||||||
begin
|
begin
|
||||||
if FCount = 0 then Exit;
|
if FCount = 0 then Exit;
|
||||||
Changing;
|
Changing;
|
||||||
For I:=0 to FCount-1 do
|
if FOwnsObjects then
|
||||||
Flist^[I].FString:='';
|
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;
|
FCount:=0;
|
||||||
SetCapacity(0);
|
SetCapacity(0);
|
||||||
Changed;
|
Changed;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Procedure TStringList.Delete(Index: Integer);
|
Procedure TStringList.Delete(Index: Integer);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -1181,6 +1188,8 @@ begin
|
|||||||
Error(SlistINdexError,Index);
|
Error(SlistINdexError,Index);
|
||||||
Changing;
|
Changing;
|
||||||
Flist^[Index].FString:='';
|
Flist^[Index].FString:='';
|
||||||
|
if FOwnsObjects then
|
||||||
|
FreeAndNil(Flist^[Index].FObject);
|
||||||
Dec(FCount);
|
Dec(FCount);
|
||||||
If Index<FCount then
|
If Index<FCount then
|
||||||
System.Move(Flist^[Index+1],
|
System.Move(Flist^[Index+1],
|
||||||
@ -1316,6 +1325,7 @@ end;
|
|||||||
constructor TStringList.Create;
|
constructor TStringList.Create;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
FOwnsObjects:=false;
|
||||||
FMap := TFPStrObjMap.Create;
|
FMap := TFPStrObjMap.Create;
|
||||||
FMap.OnPtrCompare := @MapPtrCompare;
|
FMap.OnPtrCompare := @MapPtrCompare;
|
||||||
FOnCompareText := @DefaultCompareText;
|
FOnCompareText := @DefaultCompareText;
|
||||||
|
Loading…
Reference in New Issue
Block a user