On Wed, 12 Oct 2016, grouchysmurf wrote:
Hi. Is there a way to pre-maturely halt TCustomApplication without causing memory leaks? Say, I have a code, where TH is a Class(TCustomApplication): ph := TH.Create(Nil); ph.Initialize; ph.ProcessOptions; ph.Run; ph.Free; When options are processed, it may happen the program needs to halt, when provided with improper parameters, for example. In such a case, I would call Help method: Procedure TH.Help(ExitCode : Byte = 0; ErrStr : String = ''); Begin { do stuff } Halt(ExitCode); End; Now, when this happens, ph is not freed, causing a minor memory leak. I don't want that. Is there a way to terminate a program with Halt but also making sure the memory has been freed properly?
Call Terminate and exit properly ? TCustomApplication has an exitcode property which will set the global exit code. Michael. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal