[fpc-devel] question about thread.WaitFor

Martin Frb lazarus at mfriebe.de
Sun Nov 11 18:41:58 CET 2018


On 11/11/2018 18:32, Martin wrote:
>
>>
>> Moreover, variables/fields are only destroyed with .free, not with 
>> thread termination, so why does it matter?
>>
>
> If SomeHandler is the method of an object that is about to be 
> destroyed, then it must be ensured, that it will not be called after 
> (or it will access the freed object).
> I encountered some code, that called only WaitFor. And, as you 
> confirmed, this is not enough. The message is still on the queue, and 
> when SomeHandler is called eventually it behaves badly.
Actually, its a bit diff.

The queued event gets removed in Thread.Destroy (I had not checked there).
But in the case I was debugging, some objects where left in memory that 
relied on the call...

Anyway found what I needed.



More information about the fpc-devel mailing list