From 30146193bb6be1dc265936e1cb33d2d3096ddb2b Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 31 Jan 2019 22:24:21 +0000 Subject: [PATCH] LazLogger: Check the callback in a more thread save manner git-svn-id: trunk@60265 - --- components/lazutils/lazlogger.pas | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/lazutils/lazlogger.pas b/components/lazutils/lazlogger.pas index 28769c51ea..d69b928ab3 100644 --- a/components/lazutils/lazlogger.pas +++ b/components/lazutils/lazlogger.pas @@ -711,6 +711,7 @@ end; procedure TLazLoggerFile.DoDbgOut(s: string); var Handled: Boolean; + CB: TLazLoggerWriteEvent; begin if not IsInitialized then Init; @@ -729,10 +730,11 @@ begin FDebugNestAtBOL := (s[length(s)] in [#10,#13]); end; - if OnDbgOut <> nil then + CB := OnDbgOut; + if CB <> nil then begin Handled := False; - OnDbgOut(Self, s, Handled); + CB(Self, s, Handled); if Handled then Exit; end; @@ -743,6 +745,7 @@ end; procedure TLazLoggerFile.DoDebugLn(s: string); var Handled: Boolean; + CB: TLazLoggerWriteEvent; begin if not IsInitialized then Init; @@ -753,10 +756,11 @@ begin end; FDebugNestAtBOL := True; - if OnDebugLn <> nil then + CB := OnDebugLn; + if CB <> nil then begin Handled := False; - OnDebugLn(Self, s, Handled); + CB(Self, s, Handled); if Handled then Exit; end;