IdeIntf: Prevent bogus entries with a non-contiguous enum in TEnumPropertyEditor. Issue #39832.

(cherry picked from commit 686b056fcf)
This commit is contained in:
juha 2022-08-11 08:18:49 +03:00 committed by Maxim Ganetsky
parent cd997e0308
commit cd3d8a368b

View File

@ -3836,7 +3836,8 @@ begin
L := OrdValue;
TypeData := GetTypeData(GetPropType);
with TypeData^ do
if (L < MinValue) or (L > MaxValue) then L := MaxValue;
if (L < MinValue) or (L > MaxValue) then
L := MaxValue;
Result := GetEnumName(GetPropType, L);
end;
@ -3852,13 +3853,17 @@ procedure TEnumPropertyEditor.GetValues(Proc: TGetStrProc);
var
I: Integer;
EnumType: PTypeInfo;
s: ShortString;
s, EnumUnitName: String;
begin
EnumType := GetPropType;
EnumUnitName := GetPropTypeUnitName;
with GetTypeData(EnumType)^ do
for I := MinValue to MaxValue do begin
s := GetEnumName(EnumType, I);
Proc(s);
// An empty string and the enum's unit name happen in gaps
// of a non-contiguous enum. Why the unit name? A bug in FPC code?
if (s <> '') and (s <> EnumUnitName) then
Proc(s);
end;
end;