mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 18:58:04 +02:00
FpDebug: WorkerQueue, protect with try finally
git-svn-id: trunk@63834 -
This commit is contained in:
parent
b2b157269c
commit
c15f2179e9
@ -420,16 +420,19 @@ begin
|
||||
|
||||
if (OldState in [TWSTATE_NEW, TWSTATE_WAIT_WORKER]) then begin
|
||||
(* State is now either TWSTATE_RUNNING or TWSTATE_WAIT_WORKER *)
|
||||
if not StopRequested then
|
||||
DoExecute;
|
||||
try
|
||||
if not StopRequested then
|
||||
DoExecute;
|
||||
|
||||
OldState := InterLockedExchange(FState, TWSTATE_DONE);
|
||||
if (OldState in [TWSTATE_WAITING, TWSTATE_WAIT_WORKER, TWSTATE_CANCEL]) then
|
||||
RTLeventSetEvent(MyWorkerThread.Queue.MainWaitEvent)
|
||||
else
|
||||
// If other threads have a ref, they may call WaitForFinish and read data from this.
|
||||
if (InterLockedExchangeAdd(FRefCnt, 0) > 1) then
|
||||
WriteBarrier;
|
||||
finally
|
||||
OldState := InterLockedExchange(FState, TWSTATE_DONE);
|
||||
if (OldState in [TWSTATE_WAITING, TWSTATE_WAIT_WORKER, TWSTATE_CANCEL]) then
|
||||
RTLeventSetEvent(MyWorkerThread.Queue.MainWaitEvent)
|
||||
else
|
||||
// If other threads have a ref, they may call WaitForFinish and read data from this.
|
||||
if (InterLockedExchangeAdd(FRefCnt, 0) > 1) then
|
||||
WriteBarrier;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user