mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 13:06:18 +02:00
* enhanced how observers are notified by subjects on destroying
git-svn-id: trunk@13853 -
This commit is contained in:
parent
74c09e2268
commit
65bca0a26d
@ -250,6 +250,8 @@ begin
|
|||||||
FComponentState := FComponentState - [csFreeNotification];
|
FComponentState := FComponentState - [csFreeNotification];
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{ disabled this code: do we really have to notify the child components also? Each observer
|
||||||
|
should register itself to it's subject! }
|
||||||
{If assigned(FComponents) then
|
{If assigned(FComponents) then
|
||||||
For Runner:=0 To FComponents.Count-1 do
|
For Runner:=0 To FComponents.Count-1 do
|
||||||
TComponent(FComponents.Items[Runner]).Notification(AComponent,Operation);}
|
TComponent(FComponents.Items[Runner]).Notification(AComponent,Operation);}
|
||||||
@ -413,22 +415,16 @@ Destructor TComponent.Destroy;
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
I : Integer;
|
I : Integer;
|
||||||
C : TComponent;
|
L : TList;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Destroying;
|
Destroying;
|
||||||
If Assigned(FFreeNotifies) then
|
If Assigned(FFreeNotifies) then
|
||||||
begin
|
begin
|
||||||
I := FFreeNotifies.Count-1;
|
L := FFreeNotifies;
|
||||||
While I >= 0 do
|
FFreenotifies:=Nil;
|
||||||
begin
|
for I := L.Count - 1 downto 0 do
|
||||||
C:=TComponent(FFreeNotifies.Items[I]);
|
TComponent(FFreeNotifies.Items[I]).Notification(self,opRemove);
|
||||||
FFreeNotifies.Delete(I);
|
L.Free;
|
||||||
C.RemoveNotification(self);
|
|
||||||
C.Notification(self,opRemove);
|
|
||||||
I:=FFreeNotifies.Count-1;
|
|
||||||
end;
|
|
||||||
FreeAndNil(FFreeNotifies);
|
|
||||||
end;
|
end;
|
||||||
DestroyComponents;
|
DestroyComponents;
|
||||||
If FOwner<>Nil Then FOwner.RemoveComponent(Self);
|
If FOwner<>Nil Then FOwner.RemoveComponent(Self);
|
||||||
|
Loading…
Reference in New Issue
Block a user