[Lazarus] TSynEdit bug in destructor?

Martin lazarus at mfriebe.de
Tue Nov 8 16:49:37 CET 2011

On 08/11/2011 15:39, Bart wrote:
> It creates and frees a TSynEdit at runtime.
> Note that pressing Ctrl-F4 will also free the TSynEdit.
> If you run the program and press the Free button, the TSynEdit gets freed OK.
> If however you press Ctrl+F4 and at that moment the TSynEdit has
> focus, then you get a warning when freeing the TSynEdit:
> WARNING: TLCLComponent.Destroy with LCLRefCount>0. Hint: Maybe the component is
> processing an event?

You need to do  a callstack, of where you handle ctrl-f4.

But I think the bug is in your code. It is not necessarily synedit specific.

If SynEdit was focussed then SynEdit message handler may be called, the 
form key handler may run inside (inherited) that handler.

If you destroy synedit while one of it's methods is executed, then that 
is what you get.

Look at sourceEditor. you can somehow give synedit to the application 
for destruction OnIdle

More information about the Lazarus mailing list