Browse Source

Fixed: TThreadSafeNotifyEvent secure terminate

PascalCoin 6 years ago
parent
commit
3a15b52e71
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/core/UNode.pas

+ 3 - 2
src/core/UNode.pas

@@ -1182,7 +1182,6 @@ begin
   FMessages := TStringList.Create;
   FMessages := TStringList.Create;
   FPendingNotificationsList := TPCThreadList.Create('TNodeNotifyEvents_PendingNotificationsList');
   FPendingNotificationsList := TPCThreadList.Create('TNodeNotifyEvents_PendingNotificationsList');
   FThreadSafeNodeNotifyEvent := TThreadSafeNodeNotifyEvent.Create(Self);
   FThreadSafeNodeNotifyEvent := TThreadSafeNodeNotifyEvent.Create(Self);
-  FThreadSafeNodeNotifyEvent.FreeOnTerminate := true; // This is to prevent locking when freeing component
   Node := _Node;
   Node := _Node;
 end;
 end;
 
 
@@ -1191,6 +1190,8 @@ begin
   if Assigned(FNode) then FNode.FNotifyList.Remove(Self);
   if Assigned(FNode) then FNode.FNotifyList.Remove(Self);
   FThreadSafeNodeNotifyEvent.FNodeNotifyEvents := Nil;
   FThreadSafeNodeNotifyEvent.FNodeNotifyEvents := Nil;
   FThreadSafeNodeNotifyEvent.Terminate;
   FThreadSafeNodeNotifyEvent.Terminate;
+  FThreadSafeNodeNotifyEvent.WaitFor;
+  FreeAndNil(FThreadSafeNodeNotifyEvent);
   FreeAndNil(FPendingNotificationsList);
   FreeAndNil(FPendingNotificationsList);
   FreeAndNil(FMessages);
   FreeAndNil(FMessages);
   inherited;
   inherited;
@@ -1247,7 +1248,7 @@ end;
 constructor TThreadSafeNodeNotifyEvent.Create(ANodeNotifyEvents: TNodeNotifyEvents);
 constructor TThreadSafeNodeNotifyEvent.Create(ANodeNotifyEvents: TNodeNotifyEvents);
 begin
 begin
   FNodeNotifyEvents := ANodeNotifyEvents;
   FNodeNotifyEvents := ANodeNotifyEvents;
-  Inherited Create(false);
+  Inherited Create(False);
 end;
 end;
 
 
 procedure TThreadSafeNodeNotifyEvent.SynchronizedProcess;
 procedure TThreadSafeNodeNotifyEvent.SynchronizedProcess;