Re: Newbie question about release, freeAndNil, etc
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 25 Aug 2005 22:41:13 +0200
"swansnow" <schultz@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1125001356.095726.273210@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Thank for your thoughtful reply, Rob. A quick question, though. You
> wrote:
>> I recommend you free modal dialogs when ShowModal
>> returns. That means
>> you have code like this:
>
>> LViewerOptions := TFrmViewerOptions.Create(nil);
>> try
>> LViewerOptions.ShowModal;
>> finally
>> LViewerOptions.Free;
>> end;
>
> Are you suggesting that calling release is unnecessary? and doing
> LViewerOptions:= nil is unnecessary a well?
The LViewerOptions variable is used only in this fragment. It's left
to contain a dangling reference, but it's never used again until it
goes out of scope. (It would be a bad habit to do this with global
variables.)
> I'm not really sure what release actually does...
Release _is_ Free. Only it uses a trick to decouple the actual freeing
from the call, so pending Windows messages can be handled. The trick
also involves a Windows message; it waits in line like a good citizen
and causes the form to kill itself only when it's safe.
Groetjes,
Maarten Wiltink
.
- References:
- Newbie question about release, freeAndNil, etc
- From: swansnow
- Re: Newbie question about release, freeAndNil, etc
- From: Rob Kennedy
- Re: Newbie question about release, freeAndNil, etc
- From: swansnow
- Newbie question about release, freeAndNil, etc
- Prev by Date: Re: Newbie question about release, freeAndNil, etc
- Next by Date: Re: OOP style
- Previous by thread: Re: Newbie question about release, freeAndNil, etc
- Next by thread: Re: Newbie question about release, freeAndNil, etc
- Index(es):