Răsfoiți Sursa

--- Merging r14295 into '.':
U rtl/objpas/classes/collect.inc

git-svn-id: tags/release_2_4_0@14308 -

marco 15 ani în urmă
părinte
comite
58b3857d10
1 a modificat fișierele cu 23 adăugiri și 3 ștergeri
  1. 23 3
      rtl/objpas/classes/collect.inc

+ 23 - 3
rtl/objpas/classes/collect.inc

@@ -139,19 +139,39 @@ end;
 
 Procedure TCollection.SetPropName;
 
+Var
+  TheOwner : TPersistent;
+  PropList : PPropList;
+  I, PropCount : Integer;
+
 begin
-  //!! Should be replaced by the proper routines.
   FPropName:='';
+  TheOwner:=GetOwner;
+  if (TheOwner=Nil) Or (TheOwner.Classinfo=Nil) Then Exit;
+  // get information from the owner RTTI
+  PropCount:=GetPropList(TheOwner, PropList);
+  Try
+    For I:=0 To PropCount-1 Do
+      If (PropList^[i]^.PropType^.Kind=tkClass) And
+         (GetObjectProp(TheOwner, PropList^[i], ClassType)=Self) Then
+        Begin
+          FPropName:=PropList^[i]^.Name;
+          Exit;
+        End;
+  Finally
+    FreeMem(PropList);
+  End;
 end;
 
 
 function TCollection.GetPropName: string;
 
-Var TheOWner : TPersistent;
+Var
+  TheOwner : TPersistent;
 
 begin
   Result:=FPropNAme;
-  TheOWner:=GetOwner;
+  TheOwner:=GetOwner;
   If (Result<>'') or (TheOwner=Nil) Or (TheOwner.Classinfo=Nil) then exit;
   SetPropName;
   Result:=FPropName;