mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-02 08:30:20 +02:00
* fixed FFreeOnTerminate handing in destructor + better comments
git-svn-id: trunk@7617 -
This commit is contained in:
parent
51ebaa592f
commit
e93d612f4a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user