#1 Re: PDF Engine » Runtime error 216 in SynGdiPlus Finalization » 2018-04-03 23:51:51

This seems to do the trick! Tomorrow I do some more testing to be absolutely sure.
Thanks you so much.

#2 Re: PDF Engine » Runtime error 216 in SynGdiPlus Finalization » 2018-03-30 17:06:59

The runtime error is raised before reaching the TPrintPreview.Destroy and TPaperPreview.Destroy breakpoints. 
TGDIPlusSubset.Destroy is executed before the SynPDF, SynCrypto, SynCommons and SynGDI finalization.

I made a small video showing the debugging. The runtime error itself isn't shown because only the Delphi Environment window was captured.
http://173.236.46.37/Runtime216.mp4

#3 Re: PDF Engine » Runtime error 216 in SynGdiPlus Finalization » 2018-03-28 15:41:50

Thanks for your suggestion.
It didn't solve the problem.
Debugging learns me that Startup(fToken,Input,fStartupHook) = stOk. This begin-end block is not executed.

#4 Re: PDF Engine » Runtime error 216 in SynGdiPlus Finalization » 2018-03-27 18:01:47

I distributed the application on a Windows 7, same problem.

#5 Re: PDF Engine » Runtime error 216 in SynGdiPlus Finalization » 2018-03-27 17:00:01

Yesterday I posted my question on the DelphiArea forum but no answer yet.

My application is a VCL Forms application.

I din't try mORMotReport.pas since I'm using Print Preview for many years now. I prefer to keep using Print Preview if possible.

I changed the finalization without success.
If I debug trace into (F7) the finalization I enter the TGDIPlus.Destroy destructor.
fStartupHook.UnHook(fStartupHookToken) is the command that causes the problem.

destructor TGDIPlus.Destroy;
begin
  if fToken<>0 then begin
    if Assigned(fStartupHook.UnHook) then // may be nil e.g. for Win64
      fStartupHook.UnHook(fStartupHookToken);
    Shutdown(fToken);
    fToken := 0;
  end;
  UnLoad;
  inherited Destroy;
end;

#6 Re: PDF Engine » Runtime error 216 in SynGdiPlus Finalization » 2018-03-26 15:43:21

Thanks for your help.

I'm using the PDF engine together with the "Print Preview" component (DelphiArea.com website).
I included the {$DEFINE SYNOPSE} compiler directive in the project options.
This should be enough for the Print Preview component to take care of everything if I understood correctly.
In my own project units I don't have any link to SynPDF.
Printing a PDF works fine, the error occurs after closing the application.
If I remove the compiler directive (in other words, when I don't use the PDF engine), no error occurs.

Where should I put the "FreeAndNil(Gdip)"?

#7 PDF Engine » Runtime error 216 in SynGdiPlus Finalization » 2018-03-26 03:07:43

ToRag
Replies: 14

Hi,

using Delphi XE and SynPDF v1.18 on Windows 10:

PDF creation works fine but after closing my application I get runtime error 216.
I traced it down to the finalization of unit SynGdiPlus.

finalization
  Gdip.Free;
  Windows.DeleteCriticalSection(GdipCS);
end.

Gdip.Free causes the problem, so Windows.DeleteCriticalSection(GdipCS) is skipped when debugging.

Any help appreciated.

Regards,
Tom

Board footer

Powered by FluxBB