Pārlūkot izejas kodu

The documentation says that a "BeginThread" needs to be followed by a "CloseThread". The implementation of TThread did not respect this yet.

Note: The only RTL where this could lead to problems is for BeOS with the old threading implementation as this does not use "BeginThread" at all (the newer implementation does).

rtl/objpas/classes/classes.inc, TThread.Destroy:
  * call "CloseThread" if the thread handle is valid (mimics the logic of the Windows RTL)
rtl/win/tthread.inc, TThread.SysDestroy:
  * remove the call to "CloseHandle"; this is done by "CloseThread" afterwards

git-svn-id: trunk@24313 -
svenbarth 12 gadi atpakaļ
vecāks
revīzija
bd7cc36ea6
2 mainītis faili ar 4 papildinājumiem un 2 dzēšanām
  1. 4 1
      rtl/objpas/classes/classes.inc
  2. 0 1
      rtl/win/tthread.inc

+ 4 - 1
rtl/objpas/classes/classes.inc

@@ -191,8 +191,11 @@ end;
 
 destructor TThread.Destroy;
 begin
-  if not FExternalThread then
+  if not FExternalThread then begin
     SysDestroy;
+    if FHandle <> TThreadID(0) then
+      CloseThread(FHandle);
+  end;
   RemoveQueuedEvents(Self);
   DoneSynchronizeEvent;
   { set CurrentThreadVar to Nil? }

+ 0 - 1
rtl/win/tthread.inc

@@ -32,7 +32,6 @@ begin
             Start;
           WaitFor;
         end;
-      CloseHandle(FHandle);
     end;
 
   FFatalException.Free;