[Lazarus] Difference between FreeThenNil and FreeAndNil

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Wed Apr 27 13:18:52 CEST 2011



On Wed, 27 Apr 2011, Alexander Klenin wrote:

> On Wed, Apr 27, 2011 at 21:53,  <michael.vancanneyt at wisa.be> wrote:
>>> http://bugs.freepascal.org/view.php?id=16035
>>
>> But what does this have to do with the problem you mention in FreeAndNil ?
>>
>> It's rebuilding a component tree, while part of the tree is still being
>> destroyed. That this will go wrong seems logical to me, but irrelevant to
>> FreeAndNil.
>
> As you can see from the linked discussion,
> currently implemented workaround involves FreeAndNil.
> I can imagine a similar bug which might require FreeThenNil instead.

I didn't see any linked discussion in the indicated page.

All I can conclude from this page is that there is a bug in TAChart, most
likely returning children in GetChildren, which are in fact no longer there.
But that is just guesswork, and still I fail to see the link with FreeAndNil.

If I see things in mails like like
"This code is so complicated, I can not understand what is going on."
Then I automatically think "Badly written code" and therefore 'error-prone'.

But never mind.

Michael.




More information about the Lazarus mailing list