소스 검색

* Fix for bug #21691

git-svn-id: trunk@20779 -
michael 13 년 전
부모
커밋
d3fa1b4979
2개의 변경된 파일21개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 0
      rtl/objpas/classes/classesh.inc
  2. 20 5
      rtl/objpas/classes/collect.inc

+ 1 - 0
rtl/objpas/classes/classesh.inc

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

+ 20 - 5
rtl/objpas/classes/collect.inc

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