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

2016-10-21 Thread Lars
On Mon, October 17, 2016 12:18 am, grouchysmurf wrote: > Hi. > > >>> I ended up doing exactly that though it feels like an ugly thoug[h] >>> incomplete hack. Thanks for the tip. > >> Why a hack? >> System.ExitCode is meant for returning exitcodes. >> > > Being forced to forfeit one or two layers o

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

2016-10-17 Thread Bart
On 10/17/16, grouchysmurf wrote: >> Why a hack? >> System.ExitCode is meant for returning exitcodes. > > Being forced to forfeit one or two layers of abstraction in an object > oriented environment does sound like a hack to me. A direct access to > system variables is inelegant to my unexperienc

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

2016-10-16 Thread grouchysmurf
Hi. >> I ended up doing exactly that though it feels like an ugly thoug[h] >> incomplete hack. Thanks for the tip. > Why a hack? > System.ExitCode is meant for returning exitcodes. Being forced to forfeit one or two layers of abstraction in an object oriented environment does sound like a hack

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

2016-10-16 Thread Bart
On 10/16/16, grouchysmurf wrote: >> Probably you can set system.ExitCode before calling Terminate. > > I ended up doing exactly that though it feels like an ugly thoug > incomplete hack. Thanks for the tip. Why a hack? System.ExitCode is meant for returning exitcodes. an overloaded TCustomApplic

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

2016-10-16 Thread grouchysmurf
> Probably you can set system.ExitCode before calling Terminate. I ended up doing exactly that though it feels like an ugly thoug incomplete hack. Thanks for the tip. Łukasz ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freep

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

2016-10-13 Thread Santiago A.
El 13/10/2016 a las 15:07, Graeme Geldenhuys escribió: > On 2016-10-13 13:48, Sven Barth wrote: >> 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. > > Wow, that's a bit harsh. Overriding the whole m

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

2016-10-13 Thread grouchysmurf
Hi. > Anyway, I think that when the application is closed all the allocated > memory is freed, memory leaks survive as long as the application is > running. So wondering about what's in memory after a halt makes no > sense, everything is freed. I am not very familiar with internals of system pr

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

2016-10-13 Thread grouchysmurf
Hi. > I would also rewrite that with a try..finally as in: Thanks. This is what I am planning to do eventually but as for now I am learning the ropes -- freepascal is kind of new to me and I am slowly learning its new features. Last Pascal I've been programming in was TP 6.0 with TurboVisi

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

2016-10-13 Thread grouchysmurf
Hi. > Call Terminate and exit properly ? > TCustomApplication has an exitcode property which will set the global exit > code. This feature either undocumented or I am just too stupid to find it. Mind if I ask you to point me directly to the documentation? I believe it would have to be something

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

2016-10-13 Thread Sven Barth
Am 13.10.2016 15:07 schrieb "Graeme Geldenhuys" < mailingli...@geldenhuys.co.uk>: > > On 2016-10-13 13:48, Sven Barth wrote: > > 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. > > > Wow, that's a

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

2016-10-13 Thread Graeme Geldenhuys
On 2016-10-13 13:48, Sven Barth wrote: > 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. Wow, that's a bit harsh. Overriding the whole meaning of the try..finally language feature. Then I would rec

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

2016-10-13 Thread Sven Barth
Am 13.10.2016 10:09 schrieb "Graeme Geldenhuys" < mailingli...@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;

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

2016-10-13 Thread Santiago A.
El 13/10/2016 a las 10:09, Graeme Geldenhuys escribió: > 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; May be I'm wrong, but I think that Halt(n) is a nuclear bomb, it closes the

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

2016-10-13 Thread Bart
On 10/13/16, Michael Van Canneyt wrote: > Call Terminate and exit properly ? > TCustomApplication has an exitcode property which will set the global exit > code. AFAICS not in fpc 3.0.0 (TATCApp = class(TCustomApplication) procedure TATCApp.OnExcept(Sender: TObject; E: Exception); begin writ

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

2016-10-13 Thread Graeme Geldenhuys
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;

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

2016-10-13 Thread Michael Van Canneyt
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 pr

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

2016-10-12 Thread grouchysmurf
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