LazLogger: Check the callback in a more thread save manner

git-svn-id: trunk@60265 -
This commit is contained in:
martin 2019-01-31 22:24:21 +00:00
parent 131d04802a
commit 30146193bb

View File

@ -711,6 +711,7 @@ end;
procedure TLazLoggerFile.DoDbgOut(s: string); procedure TLazLoggerFile.DoDbgOut(s: string);
var var
Handled: Boolean; Handled: Boolean;
CB: TLazLoggerWriteEvent;
begin begin
if not IsInitialized then Init; if not IsInitialized then Init;
@ -729,10 +730,11 @@ begin
FDebugNestAtBOL := (s[length(s)] in [#10,#13]); FDebugNestAtBOL := (s[length(s)] in [#10,#13]);
end; end;
if OnDbgOut <> nil then CB := OnDbgOut;
if CB <> nil then
begin begin
Handled := False; Handled := False;
OnDbgOut(Self, s, Handled); CB(Self, s, Handled);
if Handled then if Handled then
Exit; Exit;
end; end;
@ -743,6 +745,7 @@ end;
procedure TLazLoggerFile.DoDebugLn(s: string); procedure TLazLoggerFile.DoDebugLn(s: string);
var var
Handled: Boolean; Handled: Boolean;
CB: TLazLoggerWriteEvent;
begin begin
if not IsInitialized then Init; if not IsInitialized then Init;
@ -753,10 +756,11 @@ begin
end; end;
FDebugNestAtBOL := True; FDebugNestAtBOL := True;
if OnDebugLn <> nil then CB := OnDebugLn;
if CB <> nil then
begin begin
Handled := False; Handled := False;
OnDebugLn(Self, s, Handled); CB(Self, s, Handled);
if Handled then if Handled then
Exit; Exit;
end; end;