[fpc-devel] GetPropList gives AV when called

Graeme Geldenhuys graeme at mastermaths.co.za
Fri Dec 9 15:28:10 CET 2005


Hi,

Another issue in FPC 2.0.1 on Win2000 that doesn't occur in Delphi. As I 
mentioned before, I am busy porting our Delphi app. The Delphi app had 
1400 unit tests, which I am now busy working through to find out why 
they are failing under FPC.

In the code below, tiListToStream calls tiGetPropertyNames which 
internally calls GetPropList (the first one), which then throws an 
Access Violation and reports a error in GetTypeData. See error at end of 
email.

I traced into GetPropList to line 663 which assigns the 
@InsertPropnosort  event handler.

begin
   if sorted then
     DoInsertProp:=@InsertProp
   else
     DoInsertProp:=@InsertPropnosort;      <<== gives AV here
<...snip...>

Any ideas on this one?

----------------------------------------------

procedure tiListToStream(AStream : TStream ;
                          AList : TtiObjectList) ;
var
   lFields  : TStringList ;
begin
   Assert(AStream<>nil, 'AStream not assigned');
   Assert(AList.TestValid, cErrorTIPerObjAbsTestValid);
   Assert(AList.Count > 0, 'AList.Count = 0');
   lFields := TStringList.Create ;
   try
     tiGetPropertyNames(AList.Items[0], lFields );
<...snip...>


-------------------------------------------------
procedure tiGetPropertyNames( pPersistent : TtiBaseObjectClass ;
                               pSL : TStringList ;
                               pPropFilter : TTypeKinds = ctkSimple ) ;
var
   lCount : integer ;
   lSize  : integer ;
   lList  : PPropList ;
   i : integer ;
   lPropFilter : TTypeKinds ;
begin
   Assert( pSL <> nil, 'pSL not assigned.' ) ;
   lPropFilter := pPropFilter ;

   pSL.Clear ;

   lCount  := GetPropList(pPersistent.ClassInfo, lPropFilter, nil, false);
   lSize   := lCount * SizeOf(Pointer);
   GetMem(lList, lSize);
   try
     GetPropList(pPersistent.ClassInfo, lPropFilter, lList, false);
     for i := 0 to lcount - 1 do
       pSL.Add( lList^[i]^.Name ) ;
   finally
     FreeMem( lList, lSize ) ;
   end ;
end ;
-------------------------------------------------

<Error>
   <Message>TTestTIUtils.tiListToStreamDefault: Access violation</Message>
   <ExceptionClass>EAccessViolation</ExceptionClass>
   <ExceptionMessage>Access violation</ExceptionMessage>
   <SourceUnitName>../objpas/typinfo.pp</SourceUnitName>
   <LineNumber>478</LineNumber>
   <FailedMethodName>GETTYPEDATA</FailedMethodName>
</Error>
---------------------------------------------------

Regards,
   - Graeme -






More information about the fpc-devel mailing list