* Fix for bug #21691

git-svn-id: trunk@20779 -
This commit is contained in:
michael 2012-04-10 07:49:40 +00:00
parent 75eaad88fb
commit d3fa1b4979
2 changed files with 21 additions and 5 deletions

View File

@ -487,6 +487,7 @@ type
function GetPropName: string;
procedure InsertItem(Item: TCollectionItem);
procedure RemoveItem(Item: TCollectionItem);
procedure DoClear;
protected
{ Design-time editor support }
function GetAttrCount: Integer; dynamic;

View File

@ -304,7 +304,11 @@ end;
destructor TCollection.Destroy;
begin
If Assigned(FItems) Then Clear;
If Assigned(FItems) Then
begin
BeginUpdate; // Prevent OnChange
DoClear;
end;
FItems.Free;
Inherited Destroy;
end;
@ -333,11 +337,22 @@ end;
procedure TCollection.BeginUpdate;
begin
inc(FUpdateCount);
inc(FUpdateCount);
end;
procedure TCollection.Clear;
begin
BeginUpdate;
try
DoClear;
finally
EndUpdate;
end;
end;
procedure TCollection.DoClear;
begin
If Assigned(FItems) then
While FItems.Count>0 do TCollectionItem(FItems.Last).Free;
@ -346,9 +361,9 @@ end;
procedure TCollection.EndUpdate;
begin
dec(FUpdateCount);
if FUpdateCount=0 then
Changed;
dec(FUpdateCount);
if FUpdateCount=0 then
Changed;
end;