소스 검색

Fixed: TThreadSafeNotifyEvent secure terminate

PascalCoin 6 년 전
부모
커밋
3a15b52e71
1개의 변경된 파일3개의 추가작업 그리고 2개의 파일을 삭제
  1. 3 2
      src/core/UNode.pas

+ 3 - 2
src/core/UNode.pas

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