Răsfoiți Sursa

* fixed FFreeOnTerminate handing in destructor + better comments

git-svn-id: trunk@7617 -
Jonas Maebe 18 ani în urmă
părinte
comite
e93d612f4a
1 a modificat fișierele cu 5 adăugiri și 3 ștergeri
  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