🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16032

Re: log off/ application terminate

#16032
From: Eudy Silva
Date: Wed, 04 Jun 2003 15:40
39 lines
2421 bytes
Duane Hebert wrote:
 > I've added an on close query as below:
 >
 > void __fastcall TControlForm::FormCloseQuery(TObject *Sender,
 >       bool &CanClose)
 > {
 >   CanClose = false;
 >    if(CompWatchdog) {
 >         delete CompWatchdog;
 >         CompWatchdog = NULL;
 >    }
 >    CanClose = true;
 >
 > }
 >
 >
 > Now my watchdog is reset as expected.  A couple of questions though.
 > Is this the proper way to use this event?

Yes. There's no need to set CanClose to false if you'll
set it to true later on, anyway. Also note CanClose defaults
to true, so there's no need to set CanClose at all, in this
particular case.

 > Additionally, I have a cleanup function that deletes all of my
 > objects.
 > I currently call it in the dtor.  Should I move this as well?
 > I can't really debug for leaks when I do a logoff...

Yes. Since the FormQueryClose is always called (be it in a normal
form close  or a user logo off) the clean up should be done in
this event handler.
Just make sure you don't do anything that might upset the form
destructor (it will still be called in case it's a normal
form close).

Thanks Remy for pointing out a simpler solution.

Eudy
Technical Details
Message-ID: <3EDE12F8.9030105@directnet.com.br>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3edccd80@newsgroups.borland.com> <3EDD5EE0.9060804@fake.com> <3edd66d9$1@newsgroups.borland.com> <3edd6c58$1@newsgroups.borland.com> <3EDDE16A.5030506@iae.cta> <3eddf36a$1@newsgroups.borland.com> <3eddf72b$1@newsgroups.borland.com> <3ede0188@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,f4b8abe1a2fab575
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-06-04 08:43:36 PST
Message-ID: <3EDE12F8.9030105@directnet.com.br>
Date: Wed, 04 Jun 2003 12:40:40 -0300
From: Eudy Silva <eudy@directnet.com.br>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: log off/ application terminate
References: <3edccd80@newsgroups.borland.com> <3EDD5EE0.9060804@fake.com> <3edd66d9$1@newsgroups.borland.com> <3edd6c58$1@newsgroups.borland.com> <3EDDE16A.5030506@iae.cta> <3eddf36a$1@newsgroups.borland.com> <3eddf72b$1@newsgroups.borland.com> <3ede0188@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 200.152.8.215
X-Trace: newsgroups.borland.com 1054741115 200.152.8.215 (4 Jun 2003 08:38:35 -0700)
Lines: 40
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail