Board logo

Subject: Bug in cnDebug.pas TraceObjectWithTag/LogObjectWithTag [Print This Page]

Author: MrOuzo    Time: 2020-3-25 17:40     Subject: Bug in cnDebug.pas TraceObjectWithTag/LogObjectWithTag

Hello,

i think there is a bug in TraceObjectWithTag/LogObjectWithTag, the ATag is not evaluated

[Copy to clipboard]
CODE:
procedure TCnDebugger.TraceObjectWithTag(AObject: TObject;
  const ATag: string);
{$IFNDEF NDEBUG}
var
  List: TStringList;
  Intfs: string;
{$ENDIF}
begin
{$IFNDEF NDEBUG}
  List := nil;
  try
    List := TStringList.Create;
    try
      AddObjectToStringList(AObject, List, 0);
      Intfs := FormatObjectInterface(AObject);
      if Intfs <> '' then
      begin
        List.Add('Supports Interfaces:');
        List.Add(Intfs);
      end;
    except
      List.Add(SCnObjException);
    end;
    TraceMsgWithType('Object: ' + IntToHex(Integer(AObject), CN_HEX_DIGITS) + SCnCRLF +
      List.Text, cmtObject);
  finally
    List.Free;
  end;
{$ENDIF}
end;

i think the new code is

[Copy to clipboard]
CODE:
procedure TCnDebugger.TraceObjectWithTag(AObject: TObject;
  const ATag: string);
{$IFNDEF NDEBUG}
var
  List: TStringList;
  Intfs: string;
{$ENDIF}
begin
{$IFNDEF NDEBUG}
  List := nil;
  try
    List := TStringList.Create;
    try
      AddObjectToStringList(AObject, List, 0);
      Intfs := FormatObjectInterface(AObject);
      if Intfs <> '' then
      begin
        List.Add('Supports Interfaces:');
        List.Add(Intfs);
      end;
    except
      List.Add(SCnObjException);
    end;
    TraceMsgWithTypeTag('Object: ' + IntToHex(Integer(AObject), CN_HEX_DIGITS) + SCnCRLF +
      List.Text, cmtObject, ATag);    // <----- here
  finally
    List.Free;
  end;
{$ENDIF}
end;


Author: Passion    Time: 2020-6-2 14:09

Oh, thanks for the bug report.

Now I fix it.




Welcome to CnPack Forum (http://bbs.cnpack.org/) Powered by Discuz! 5.0.0