소스 검색

* fixed FFreeOnTerminate handing in destructor + better comments

git-svn-id: trunk@7617 -
Jonas Maebe 18 년 전
부모
커밋
e93d612f4a
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      rtl/unix/tthread.inc

+ 5 - 3
rtl/unix/tthread.inc

@@ -172,9 +172,6 @@ begin
       inherited destroy;
       exit;
     end;
-  // if someone calls .Free on a thread with
-  // FreeOnTerminate, then don't crash!
-  FFreeOnTerminate := false;
   if (FThreadID = GetCurrentThreadID) then
     begin
       if not(FFreeOnTerminate) and not FFinished then
@@ -183,6 +180,11 @@ begin
     end
   else
     begin
+      // if someone calls .Free on a thread with not(FreeOnTerminate), there
+      // is no problem. Otherwise, FreeOnTerminate must be set to false so
+      // when ThreadFunc exits the main runloop, it does try to Free itself
+      // again
+      FFreeOnTerminate := false;
       { you can't join yourself, so only for FThreadID<>GetCurrentThreadID }
       { and you can't join twice -> make sure we didn't join already       }
       if not FThreadReaped then