FpDebug: WorkerQueue, protect with try finally

git-svn-id: trunk@63834 -
This commit is contained in:
martin 2020-08-26 19:15:00 +00:00
parent b2b157269c
commit c15f2179e9

View File

@ -420,9 +420,11 @@ begin
if (OldState in [TWSTATE_NEW, TWSTATE_WAIT_WORKER]) then begin if (OldState in [TWSTATE_NEW, TWSTATE_WAIT_WORKER]) then begin
(* State is now either TWSTATE_RUNNING or TWSTATE_WAIT_WORKER *) (* State is now either TWSTATE_RUNNING or TWSTATE_WAIT_WORKER *)
try
if not StopRequested then if not StopRequested then
DoExecute; DoExecute;
finally
OldState := InterLockedExchange(FState, TWSTATE_DONE); OldState := InterLockedExchange(FState, TWSTATE_DONE);
if (OldState in [TWSTATE_WAITING, TWSTATE_WAIT_WORKER, TWSTATE_CANCEL]) then if (OldState in [TWSTATE_WAITING, TWSTATE_WAIT_WORKER, TWSTATE_CANCEL]) then
RTLeventSetEvent(MyWorkerThread.Queue.MainWaitEvent) RTLeventSetEvent(MyWorkerThread.Queue.MainWaitEvent)
@ -431,6 +433,7 @@ begin
if (InterLockedExchangeAdd(FRefCnt, 0) > 1) then if (InterLockedExchangeAdd(FRefCnt, 0) > 1) then
WriteBarrier; WriteBarrier;
end; end;
end;
end; end;
procedure TFpThreadWorkerItem.WaitForFinish(AnMainWaitEvent: PRTLEvent; procedure TFpThreadWorkerItem.WaitForFinish(AnMainWaitEvent: PRTLEvent;