View Issue Details

IDProjectCategoryView StatusLast Update
0032548LazarusLazReportpublic2017-11-30 14:55
ReporterAlexanderAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformAnyOSAnyOS VersionAny
Product VersionProduct Build 
Target VersionFixed in Version1.9 (SVN) 
Summary0032548: Can't set DebugLogger in LazLogger.pas to nil
DescriptionDebugLogger := nil; occurs to AV
Steps To Reproduceuses
  LazLogger;

var
  newLogger: TLazLoggerFile;

begin
  newLogger := DebugLogger; //will create new logger object with call GetDebugLogger()
  //bla bla bla
  DebugLogger := nil; //should close file and destroy current logger object
end;
Additional Informationproblem comes with this procedure in LazLoggerBase.pas:

procedure SetDebugLogger(ALogger: TLazLogger);
begin
  ReleaseRefAndNil(TheLazLogger);
  TheLazLogger := ALogger;
  TheLazLogger.AddReference;
end;

it's call TheLazLogger.AddReference; always, even if TheLazLogger is nil

Can be fixed with checking TheLazLogger <> nil before call AddReference:

procedure SetDebugLogger(ALogger: TLazLogger);
begin
  ReleaseRefAndNil(TheLazLogger);
  TheLazLogger := ALogger;
  if TheLazLogger <> nil then
    TheLazLogger.AddReference;
end;
TagsNo tags attached.
Fixed in Revision32548
LazTarget-
Widgetset
Attached Files

Activities

Cyrax

2017-10-14 14:00

reporter   ~0103422

Someone move this to Lazarus side of bug tracker, please.

Martin Friebe

2017-11-30 14:55

manager   ~0104366

Why not calling DebugLogger.CloseFile ?

The logger (even user supplied) is destroyed in finalization of the unit.

Setting to nil makes little sense, because the next time any "debugln" is called, it will be re-created.

----------
I "fixed" it anyway

Issue History

Date Modified Username Field Change
2017-10-14 09:21 Alexander New Issue
2017-10-14 14:00 Cyrax Note Added: 0103422
2017-10-14 15:24 Marco van de Voort Project FPC => Lazarus
2017-10-14 16:38 Martin Friebe Assigned To => Martin Friebe
2017-10-14 16:38 Martin Friebe Status new => assigned
2017-11-30 14:55 Martin Friebe Fixed in Revision => 32548
2017-11-30 14:55 Martin Friebe LazTarget => -
2017-11-30 14:55 Martin Friebe Note Added: 0104366
2017-11-30 14:55 Martin Friebe Status assigned => resolved
2017-11-30 14:55 Martin Friebe Fixed in Version => 1.9 (SVN)
2017-11-30 14:55 Martin Friebe Resolution open => fixed