Browse Source

* Patch from Henrique Werlang to correct sort order in GetMethods

michael 4 years ago
parent
commit
69c9c7ce6d
1 changed files with 3 additions and 2 deletions
  1. 3 2
      packages/rtl/rtti.pas

+ 3 - 2
packages/rtl/rtti.pas

@@ -731,14 +731,15 @@ begin
     Inc(MethodCount, BaseClass.StructTypeInfo.MethodCount);
     BaseClass := BaseClass.GetAncestor;
   end;
-  SetLength(Result, StructTypeInfo.MethodCount);
+  SetLength(Result, MethodCount);
   BaseClass := Self;
+  MethodCount:=0;
   while Assigned(BaseClass) do
   begin
     for A := 0 to Pred(BaseClass.StructTypeInfo.MethodCount) do
     begin
-      Dec(MethodCount);
       Result[MethodCount] := TRttiMethod.Create(BaseClass, BaseClass.StructTypeInfo.GetMethod(A));
+      Inc(MethodCount);
     end;
     BaseClass := BaseClass.GetAncestor;
   end;