mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Issue #1936: Attempt to fix EAbstractError when closing text editor
This commit is contained in:
@ -1147,10 +1147,14 @@ end;
|
|||||||
|
|
||||||
destructor TInplaceEditorLink.Destroy;
|
destructor TInplaceEditorLink.Destroy;
|
||||||
begin
|
begin
|
||||||
if Assigned(FTextEditor) then
|
if Assigned(FTextEditor) then begin
|
||||||
FTextEditor.Release;
|
FTextEditor.Free;
|
||||||
if not ((csDestroying in FPanel.ComponentState) or (csCreating in FPanel.ControlState)) then
|
end;
|
||||||
|
if not ((csDestroying in FPanel.ComponentState) or (csCreating in FPanel.ControlState)) then begin
|
||||||
|
FEdit.Free;
|
||||||
|
FButton.Free;
|
||||||
FPanel.Free;
|
FPanel.Free;
|
||||||
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1173,8 +1177,9 @@ function TInplaceEditorLink.CancelEdit: Boolean;
|
|||||||
begin
|
begin
|
||||||
Result := inherited CancelEdit;
|
Result := inherited CancelEdit;
|
||||||
if Result then begin
|
if Result then begin
|
||||||
if Assigned(FTextEditor) then
|
if Assigned(FTextEditor) then begin
|
||||||
FTextEditor.Close;
|
FTextEditor.Close;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1184,14 +1189,8 @@ var
|
|||||||
begin
|
begin
|
||||||
Result := not FStopping;
|
Result := not FStopping;
|
||||||
if FStopping then Exit;
|
if FStopping then Exit;
|
||||||
if Assigned(FTextEditor) then begin
|
NewText := FEdit.Text;
|
||||||
NewText := FTextEditor.GetText;
|
FModified := NewText <> FCellText;
|
||||||
FModified := FTextEditor.Modified;
|
|
||||||
FTextEditor.Close;
|
|
||||||
end else begin
|
|
||||||
NewText := FEdit.Text;
|
|
||||||
FModified := FEdit.Modified;
|
|
||||||
end;
|
|
||||||
Result := EndEditHelper(NewText);
|
Result := EndEditHelper(NewText);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1218,7 +1217,13 @@ begin
|
|||||||
FTextEditor.SetMaxLength(FMaxLength);
|
FTextEditor.SetMaxLength(FMaxLength);
|
||||||
FTextEditor.TableColumn := FTableColumn;
|
FTextEditor.TableColumn := FTableColumn;
|
||||||
FTextEditor.MemoText.ReadOnly := not FAllowEdit;
|
FTextEditor.MemoText.ReadOnly := not FAllowEdit;
|
||||||
FTextEditor.ShowModal;
|
if FTextEditor.ShowModal = mrOk then begin
|
||||||
|
FEdit.Text := FTextEditor.GetText;
|
||||||
|
DoEndEdit(Sender);
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
DoCancelEdit(Sender);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TInplaceEditorLink.PrepareEdit(Tree: TBaseVirtualTree;
|
function TInplaceEditorLink.PrepareEdit(Tree: TBaseVirtualTree;
|
||||||
|
@ -87,6 +87,7 @@ type
|
|||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
FModified: Boolean;
|
FModified: Boolean;
|
||||||
FStopping: Boolean;
|
FStopping: Boolean;
|
||||||
|
FClosingByApplyButton: Boolean;
|
||||||
FDetectedLineBreaks,
|
FDetectedLineBreaks,
|
||||||
FSelectedLineBreaks: TLineBreaks;
|
FSelectedLineBreaks: TLineBreaks;
|
||||||
FMaxLength: Integer;
|
FMaxLength: Integer;
|
||||||
@ -242,6 +243,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
HasSizeGrip := True;
|
HasSizeGrip := True;
|
||||||
|
FClosingByApplyButton := False;
|
||||||
// Assign linebreak values to their menu item tags, to write less code later
|
// Assign linebreak values to their menu item tags, to write less code later
|
||||||
menuWindowsLB.Tag := Integer(lbsWindows);
|
menuWindowsLB.Tag := Integer(lbsWindows);
|
||||||
menuUnixLB.Tag := Integer(lbsUnix);
|
menuUnixLB.Tag := Integer(lbsUnix);
|
||||||
@ -505,21 +507,23 @@ begin
|
|||||||
if FStopping then
|
if FStopping then
|
||||||
Exit;
|
Exit;
|
||||||
FStopping := True;
|
FStopping := True;
|
||||||
if Modified then
|
if Modified and FClosingByApplyButton then
|
||||||
|
DoPost := True
|
||||||
|
else if Modified then
|
||||||
DoPost := MessageDialog(_('Apply modifications?'), mtConfirmation, [mbYes, mbNo]) = mrYes
|
DoPost := MessageDialog(_('Apply modifications?'), mtConfirmation, [mbYes, mbNo]) = mrYes
|
||||||
else
|
else
|
||||||
DoPost := False;
|
DoPost := False;
|
||||||
if DoPost then
|
if DoPost then
|
||||||
TCustomVirtualStringTree(Owner).EndEditNode
|
ModalResult := mrOk
|
||||||
else
|
else
|
||||||
TCustomVirtualStringTree(Owner).CancelEditNode;
|
ModalResult := mrCancel;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TfrmTextEditor.btnApplyClick(Sender: TObject);
|
procedure TfrmTextEditor.btnApplyClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FStopping := True;
|
FClosingByApplyButton := True;
|
||||||
TCustomVirtualStringTree(Owner).EndEditNode;
|
Close;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user