[fpc-pascal] Generic way to pre-maturely exit TCustomApplication without memory leaks

Sven Barth pascaldragon at googlemail.com
Thu Oct 13 14:48:45 CEST 2016


Am 13.10.2016 10:09 schrieb "Graeme Geldenhuys" <
mailinglists at geldenhuys.co.uk>:
>
> On 2016-10-12 20:37, grouchysmurf wrote:
> > Say, I have a code, where TH is a Class(TCustomApplication):
> >
> >   ph := TH.Create(Nil);
> >   ph.Initialize;
> >   ph.ProcessOptions;
> >   ph.Run;
> >   ph.Free;
>
> I would also rewrite that with a try..finally as in:
>
> ph := TH.Create(nil)
> try
>   ph.Initialize;
>   ph.ProcessOptions;
>   ph.Run;
> finally
>   ph.Free;
> end;
>

That won't help with Halt() however as that will "jump" directly to the
unit finalization, ignoring any and all exception handlers along the way.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20161013/ba1047bd/attachment.html>


More information about the fpc-pascal mailing list