mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Issue #935: cancel editing in grids other than query result grids, when main page control tab changes. Fixes crash when changing tab while editing a column via table editor.
This commit is contained in:
@ -51,6 +51,7 @@ type
|
||||
// The right constructor, we need the Tree reference
|
||||
constructor Create(Tree: TVirtualStringTree; AllowEdit: Boolean); overload; virtual;
|
||||
destructor Destroy; override;
|
||||
property Tree: TVirtualStringTree read FTree;
|
||||
function PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; virtual; stdcall;
|
||||
function BeginEdit: Boolean; virtual; stdcall;
|
||||
function CancelEdit: Boolean; virtual; stdcall;
|
||||
@ -213,6 +214,8 @@ type
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
ActiveGridEditor: TBaseGridEditorLink;
|
||||
|
||||
implementation
|
||||
|
||||
@ -249,6 +252,7 @@ begin
|
||||
SendMessage(FParentForm.Handle, WM_SETREDRAW, 0, 0);
|
||||
FModified := False;
|
||||
FAllowEdit := AllowEdit;
|
||||
ActiveGridEditor := Self;
|
||||
end;
|
||||
|
||||
destructor TBaseGridEditorLink.Destroy;
|
||||
@ -258,6 +262,7 @@ var
|
||||
DoPrev: Boolean;
|
||||
begin
|
||||
inherited;
|
||||
ActiveGridEditor := nil;
|
||||
if FLastKeyDown = VK_TAB then begin
|
||||
DoPrev := ssShift in FLastShiftState;
|
||||
// Advance to next/previous visible column/node.
|
||||
|
@ -5618,13 +5618,14 @@ end;
|
||||
|
||||
|
||||
procedure TMainForm.PageControlMainChanging(Sender: TObject; var AllowChange: Boolean);
|
||||
var
|
||||
Grid: TVirtualStringTree;
|
||||
begin
|
||||
// Leave editing mode on tab changes so the editor does not stay somewhere
|
||||
Grid := ActiveGrid;
|
||||
if Assigned(Grid) and Grid.IsEditing then
|
||||
Grid.CancelEditNode;
|
||||
if Assigned(ActiveGridEditor)
|
||||
and Assigned(ActiveGridEditor.Tree)
|
||||
and ActiveGridEditor.Tree.IsEditing then begin
|
||||
LogSQL('Cancelling tree edit mode on '+ActiveGridEditor.Tree.Name, lcDebug);
|
||||
ActiveGridEditor.Tree.CancelEditNode;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user