Hello all
Implementing some generic classes for my model in Delphi 2010 I faced
strange error reported by FastMM as memory block corruption. With some
investigation and the help of SafeMM I found that for my generics
classes the function TypInfo::GetPropList (used in tiopf's
tiRTTI::tiGetPropertyNames) corrupts memory. And the strange thing is
that TypInfo::GetPropList is Delphi's original function.
I'm not sure that this problem will appear for any generic class but I
tried it with very simple classes while investigating and still faced
the same problem.
I hope that this may be of some help for those who maybe use generics
and face similar problem.
I rewrote tiRTTI::tiGetPropertyNames function with new Delphi
2010's RTTI api. Now it works fine for me.
Here is the new tiRTTI::tiGetPropertyNames function:
procedure tiGetPropertyNames(AClass : TtiBaseObjectClass;
AStringList : TStringList;
APropFilter : TTypeKinds = ctkSimple);
var
lContext: TRTTIContext;
lType: TRTTIType;
lProp: TRTTIProperty;
begin
Assert(AStringList <> nil, 'pSL not assigned.');
AStringList.Clear;
lContext := TRttiContext.Create;
try
lType := lContext.GetType( AClass);
for lProp in LType.GetProperties do
if (lProp.PropertyType.TypeKind in APropFilter) and (lProp.Visibility =
mvPublished) then
AStringList.Add( lProp.Name);
finally
lContext.Free;
end;
end;
Regards,
Alexey Yastremskiy
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
tiOPF-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tiopf-talk