From ca77ed94e42edcac70c059918f9a7e3caef9a221 Mon Sep 17 00:00:00 2001 From: Gustavo Carreno Date: Mon, 25 Sep 2023 21:08:01 +0100 Subject: [PATCH] refactor: Stop before Dispatch if App Terminated --- examples/CLI/polykermacli.lpr | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/examples/CLI/polykermacli.lpr b/examples/CLI/polykermacli.lpr index 9ad1ee8..697167d 100644 --- a/examples/CLI/polykermacli.lpr +++ b/examples/CLI/polykermacli.lpr @@ -192,16 +192,19 @@ procedure TPolyKermaCLI.DoRun; begin LoadParams; - PolyKermaSetup; - {$IFDEF UNIX} - if FpSignal(SigInt, @HandleSigInt) = signalhandler(SIG_ERR) then begin - Error({$I %FILE%}, {$I %LINE%}, Format('Failed to install signal error: %d', [ fpGetErrno ])); - Halt(1); + if not Terminated then + begin + PolyKermaSetup; + {$IFDEF UNIX} + if FpSignal(SigInt, @HandleSigInt) = signalhandler(SIG_ERR) then begin + Error({$I %FILE%}, {$I %LINE%}, Format('Failed to install signal error: %d', [ fpGetErrno ])); + Halt(1); + end; + {$ENDIF UNIX} + + FDispatcher.Run(True); + PolyKermaTearDown; end; - {$ENDIF UNIX} - - FDispatcher.Run(True); - PolyKermaTearDown; // stop program loop Terminate;