Browse Source

Fix for ToString when the object is nil.

Henrique Gottardi Werlang 1 year ago
parent
commit
5b18d98cd1
1 changed files with 7 additions and 1 deletions
  1. 7 1
      packages/rtl/src/rtti.pas

+ 7 - 1
packages/rtl/src/rtti.pas

@@ -1141,7 +1141,13 @@ begin
 
 
   case Kind of
   case Kind of
     tkBool: Result := BoolToStr(AsBoolean, True);
     tkBool: Result := BoolToStr(AsBoolean, True);
-    tkClass: Result := AsObject.ClassName;
+    tkClass:
+    begin
+      if Assigned(AsObject) then
+        Result := AsObject.ClassName
+      else
+        Result := '(empty)';
+    end;
     tkClassRef: Result := AsClass.ClassName;
     tkClassRef: Result := AsClass.ClassName;
     tkEnumeration: Result := GetEnumName(TTypeInfoEnum(TypeInfo), AsOrdinal);
     tkEnumeration: Result := GetEnumName(TTypeInfoEnum(TypeInfo), AsOrdinal);
     tkFloat: Result := FloatToStr(AsExtended, AFormatSettings);
     tkFloat: Result := FloatToStr(AsExtended, AFormatSettings);