From 1f0ff07dc2b44fa82d3fbd2bbf55338308f35632 Mon Sep 17 00:00:00 2001 From: juha Date: Sat, 11 Jul 2020 09:07:35 +0000 Subject: [PATCH] LCL: Prevent a crash when closing a form with an active in-place cell editor of a grid. Issue #37202. git-svn-id: trunk@63541 - --- lcl/grids.pas | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lcl/grids.pas b/lcl/grids.pas index 6fb5d26a1b..826a7dd21a 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -8412,19 +8412,22 @@ var begin if not EditorLocked and (Editor<>nil) and Editor.Visible then begin - WasFocused := Editor.Focused; - FEditorMode:=False; + FEditorMode := False; FGridState := gsNormal; - {$ifdef dbgGrid}DebugLnEnter('EditorHide [',Editor.ClassName,'] INIT FCol=',IntToStr(FCol),' FRow=',IntToStr(FRow));{$endif} - LockEditor; - try - DoEditorHide; - finally - if WasFocused then - SetFocus; - UnLockEditor; + if Editor.Owner<>nil then // May be nil when the form is closing. + begin + WasFocused := Editor.Focused; + {$ifdef dbgGrid}DebugLnEnter('EditorHide [',Editor.ClassName,'] INIT FCol=',IntToStr(FCol),' FRow=',IntToStr(FRow));{$endif} + LockEditor; + try + DoEditorHide; + finally + if WasFocused then + SetFocus; + UnLockEditor; + end; + {$ifdef dbgGrid}DebugLnExit('EditorHide END');{$endif} end; - {$ifdef dbgGrid}DebugLnExit('EditorHide END');{$endif} end; end;