[fpc-pascal] Checking if a TStringList already exists

Michael Van Canneyt michael at freepascal.org
Tue May 21 17:36:32 CEST 2019



On Tue, 21 May 2019, Giuliano Colla wrote:

> Il 21/05/2019 14:40, Michael Van Canneyt ha scritto:
>
>> FreeThenNil should never be necessary. FreeAndNil() should be enough 
>> for all circumstances. 
>
> In a perfect world maybe you're right. But if you're dealing with LCL, 
> you'll find it sometimes necessary, less your program segfaults, because 
> the freeing of some children is postponed, and when they're set free 
> their parent is already dead. Maybe it's a matter of bad design of some 
> LCL components or even of TApplication, but either you decide that to 
> make your project work you must redesign significant parts of LCL or you 
> give up and sadly take advantage of FreeThenNil().

In that case the lazarus devels should fix whatever causes this.

Delphi does not have this after all, so it is possible to create a set of
GUI components that does not need it. It may not be easy, but you cannot
expect a user to find out through trial and error what he should be doing.

Michael.



More information about the fpc-pascal mailing list