Menu

#135 AV in HackTPictureRegisteredFormats with Lazarus

open
nobody
None
5
2010-02-27
2010-02-27
Anonymous
No

I have the latest Lazarus, FPC and GLScene. I try to load PNG file to THudSprite. I am using TGLVfsPAK and it causes the TGLTexture loading routine to fetch the class of extension from HackTPictureRegisteredFormats. But it causes access violation on line

pFileFormats:=PAnsiChar(PInteger(@pGetFileFormats[2])^);

There is a saying // Warning: This will crash when Graphics.pas is compiled with the 'Use Debug DCUs' option.
But since I use Lazarus, it shouldn't be an issue?

Discussion

  • Daniel Bartlett

    Daniel Bartlett - 2010-02-28

    This hack is to gain access to the list of file formats registered with TPicture, there's probably a proper way to do this on FPC without this hack. It's a hack that could could stop working between Delphi versions, so has to be tested each version of Delphi that comes out.

     
  • Anonymous

    Anonymous - 2010-02-28

    I managed to bypass this with changing the code in PictureRegisteredFormats.pas
    inside GraphicClassForExtension function to

    with TPicture.Create() do
    try
    result := FindGraphicClassWithFileExt(anExtension);
    finally
    free;
    end;

    It seems to work, but I have to test it with Pak files.

     
  • Nobody/Anonymous

    Seems to work with Pak files. I think with Lazarus the hack isn't necessary.