Permalink
Browse files

Issue #8: fix crash when leaving any grid editor per OK/Cancel button…

…, e.g. the column default editor
  • Loading branch information...
ansgarbecker committed Nov 13, 2018
1 parent 41e59c8 commit b6d10d0462987fab2fc10d0e35852dd3923f553b
Showing with 23 additions and 2 deletions.
  1. +23 −2 source/grideditlinks.pas
@@ -157,9 +157,12 @@ TColumnDefaultEditorLink = class(TBaseGridEditorLink)
FCustomEdit: TButtonedEdit;
FCustomDropDown: TPopupMenu;
FBtnOK, FBtnCancel: TButton;
FEndTimer: TTimer;
procedure RadioClick(Sender: TObject);
procedure CustomEditChange(Sender: TObject);
procedure CustomDropDownClick(Sender: TObject);
procedure BtnOkClick(Sender: TObject);
procedure BtnCancelClick(Sender: TObject);
public
DefaultType: TColumnDefaultType;
DefaultText: String;
@@ -1252,7 +1255,7 @@ constructor TColumnDefaultEditorLink.Create(Tree: TVirtualStringTree);
FBtnOk.Width := 60;
FBtnOk.Top := FRadioAutoInc.Top + FRadioAutoInc.Height + m;
FBtnOk.Left := FPanel.Width - 2*m - 2*FBtnOk.Width;
FBtnOk.OnClick := DoEndEdit;
FBtnOk.OnClick := BtnOkClick;
FBtnOk.Default := True;
FBtnOk.Caption := _('OK');
@@ -1261,10 +1264,14 @@ constructor TColumnDefaultEditorLink.Create(Tree: TVirtualStringTree);
FBtnCancel.Top := FBtnOk.Top;
FBtnCancel.Width := FBtnOk.Width;
FBtnCancel.Left := FBtnOk.Left + FBtnOk.Width + m;
FBtnCancel.OnClick := DoCancelEdit;
FBtnCancel.OnClick := BtnCancelClick;
FBtnCancel.Cancel := True;
FBtnCancel.Caption := _('Cancel');
FEndTimer := TTimer.Create(FPanel);
FEndTimer.Interval := 50;
FEndTimer.Enabled := False;
FPanel.Height := FBtnOk.Top + FBtnOk.Height + m;
FRadioNothing.Anchors := [akLeft, akTop, akRight];
FRadioText.Anchors := [akLeft, akTop, akRight];
@@ -1455,6 +1462,20 @@ procedure TColumnDefaultEditorLink.CustomDropDownClick(Sender: TObject);
FModified := True;
end;
procedure TColumnDefaultEditorLink.BtnOkClick(Sender: TObject);
begin
// Timer based click on OK button, to prevent crash when theming is active
FEndTimer.OnTimer := DoEndEdit;
FEndTimer.Enabled := True;
end;
procedure TColumnDefaultEditorLink.BtnCancelClick(Sender: TObject);
begin
// Timer based click on Cancel button, to prevent crash when theming is active
FEndTimer.OnTimer := DoCancelEdit;
FEndTimer.Enabled := True;
end;

0 comments on commit b6d10d0

Please sign in to comment.