Browse Source

rtl: GetPropInfos: fixed duplicates

mattias 7 years ago
parent
commit
55ecc09268
1 changed files with 10 additions and 13 deletions
  1. 10 13
      packages/rtl/typinfo.pas

+ 10 - 13
packages/rtl/typinfo.pas

@@ -596,24 +596,21 @@ end;
 function GetPropInfos(aTIClass: TTypeInfoClass): TTypeMemberPropertyDynArray;
 function GetPropInfos(aTIClass: TTypeInfoClass): TTypeMemberPropertyDynArray;
 var
 var
   C: TTypeInfoClass;
   C: TTypeInfoClass;
-  i, Cnt, j: Integer;
+  i: Integer;
+  Names: TJSObject;
+  PropName: String;
 begin
 begin
-  Cnt:=0;
-  C:=aTIClass;
-  while C<>nil do
-  begin
-    inc(Cnt,C.PropCount);
-    C:=C.Ancestor;
-  end;
-  SetLength(Result,Cnt);
+  Result:=nil;
   C:=aTIClass;
   C:=aTIClass;
-  i:=0;
+  Names:=TJSObject.new;
   while C<>nil do
   while C<>nil do
   begin
   begin
-    for j:=0 to C.PropCount-1 do
+    for i:=0 to C.PropCount-1 do
     begin
     begin
-      Result[i]:=TTypeMemberProperty(C.Members[C.Properties[j]]);
-      inc(i);
+      PropName:=C.Properties[i];
+      if Names.hasOwnProperty(PropName) then continue;
+      TJSArray(Result).push(TTypeMemberProperty(C.Members[PropName]));
+      Names[PropName]:=true;
     end;
     end;
     C:=C.Ancestor;
     C:=C.Ancestor;
   end;
   end;