From 41d400d247bbe8c8aeba01b3bd96d2ec0b467bd3 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 6 Mar 2005 15:24:03 +0000 Subject: [PATCH] * FreeOnTerminate handling fixed --- rtl/linux/tthread.inc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rtl/linux/tthread.inc b/rtl/linux/tthread.inc index 9d33395311..236c37d6fb 100644 --- a/rtl/linux/tthread.inc +++ b/rtl/linux/tthread.inc @@ -159,7 +159,8 @@ begin LThread.FFatalException := TObject(AcquireExceptionObject); // not sure if we should really do this... // but .Destroy was called, so why not try FreeOnTerminate? - if e is EThreadDestroyCalled then LThread.FFreeOnTerminate := true; + if e is EThreadDestroyCalled then + LThread.FFreeOnTerminate := true; end; end; WRITE_DEBUG('thread done running'); @@ -195,9 +196,9 @@ end; destructor TThread.Destroy; begin - if FThreadID = GetCurrentThreadID then begin + if (FThreadID = GetCurrentThreadID) and not(FFreeOnTerminate) then raise EThreadDestroyCalled.Create('A thread cannot destroy itself except by setting FreeOnTerminate and leaving!'); - end; + // if someone calls .Free on a thread with // FreeOnTerminate, then don't crash! FFreeOnTerminate := false; @@ -321,7 +322,10 @@ end; { $Log$ - Revision 1.14 2005-03-01 20:38:49 jonas + Revision 1.15 2005-03-06 15:24:03 florian + * FreeOnTerminate handling fixed + + Revision 1.14 2005/03/01 20:38:49 jonas * fixed web bug 3387: if one called resume right after creating a suspended thread, it was possible that resume was executed before that thread had completed its initialisation in BeginThread ->