Browse Source

* Make GetEnumName safer, check actual type. Allow passing an integer

Michaël Van Canneyt 1 year ago
parent
commit
cde58d66fc
1 changed files with 6 additions and 2 deletions
  1. 6 2
      rtl/objpas/typinfo.pp

+ 6 - 2
rtl/objpas/typinfo.pp

@@ -1479,7 +1479,7 @@ begin
           Result:='';
       end;
     end
- else
+ else if TypeInfo^.Kind=tkEnumeration then
    begin
      PS:=@PT^.NameList;
      dec(Value,PT^.MinValue);
@@ -1489,7 +1489,11 @@ begin
          Dec(Value);
        end;
      Result:=PS^;
-   end;
+   end
+ else if TypeInfo^.Kind=tkInteger then
+   Result:=IntToStr(Value)
+ else
+   Result:='';  
 end;