Browse Source

* Patch from Luiz Americo to make fpobserver notifications take care of begin/endupdate (Bug ID 25820)

git-svn-id: trunk@26959 -
michael 11 years ago
parent
commit
15bb6b2c72
1 changed files with 5 additions and 3 deletions
  1. 5 3
      rtl/objpas/classes/collect.inc

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

@@ -357,7 +357,8 @@ end;
 
 
 procedure TCollection.EndUpdate;
 procedure TCollection.EndUpdate;
 begin
 begin
-  dec(FUpdateCount);
+  if FUpdateCount>0 then
+    dec(FUpdateCount);
   if FUpdateCount=0 then
   if FUpdateCount=0 then
     Changed;
     Changed;
 end;
 end;
@@ -396,7 +397,7 @@ end;
 
 
 procedure TCollection.Notify(Item: TCollectionItem;Action: TCollectionNotification);
 procedure TCollection.Notify(Item: TCollectionItem;Action: TCollectionNotification);
 begin
 begin
-  if Assigned(FObservers) then
+  if Assigned(FObservers) and (FUpdateCount = 0) then
     Case Action of
     Case Action of
       cnAdded      : FPONotifyObservers(Self,ooAddItem,Pointer(Item));
       cnAdded      : FPONotifyObservers(Self,ooAddItem,Pointer(Item));
       cnExtracting : FPONotifyObservers(Self,ooDeleteItem,Pointer(Item));
       cnExtracting : FPONotifyObservers(Self,ooDeleteItem,Pointer(Item));
@@ -419,7 +420,8 @@ procedure TCollection.Exchange(Const Index1, index2: integer);
 
 
 begin
 begin
   FItems.Exchange(Index1,Index2);
   FItems.Exchange(Index1,Index2);
-  FPONotifyObservers(Self,ooChange,Nil);
+  if FUpdateCount = 0 then
+    FPONotifyObservers(Self,ooChange,Nil);
 end;
 end;