Issue #1482: fix sporadic crash with too wide completion proposal, sync code for tab close button, fix anchor siblings on edit variable dialog

This commit is contained in:
Ansgar Becker
2025-04-02 12:15:37 +02:00
parent db9156c5b7
commit 14950f416d
3 changed files with 97 additions and 58 deletions

View File

@ -15,9 +15,12 @@ object frmEditVariable: TfrmEditVariable
OnShow = FormShow
Position = poMainFormCenter
object btnOK: TButton
Left = 159
AnchorSideRight.Control = btnCancel
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 164
Height = 31
Top = 237
Top = 241
Width = 94
Anchors = [akRight, akBottom]
BorderSpacing.Around = 6
@ -28,9 +31,13 @@ object frmEditVariable: TfrmEditVariable
OnClick = btnOKClick
end
object btnCancel: TButton
Left = 260
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 264
Height = 31
Top = 237
Top = 241
Width = 94
Anchors = [akRight, akBottom]
BorderSpacing.Around = 6
@ -40,73 +47,95 @@ object frmEditVariable: TfrmEditVariable
TabOrder = 1
end
object grpScope: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = gbValue
AnchorSideTop.Side = asrBottom
Left = 10
Height = 51
Top = 178
Width = 344
Anchors = [akLeft, akRight, akBottom]
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = btnOK
Left = 6
Height = 59
Top = 176
Width = 352
Align = alTop
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Scope'
ClientHeight = 26
ClientWidth = 340
ClientHeight = 34
ClientWidth = 348
ParentBackground = False
TabOrder = 2
object radioScopeSession: TRadioButton
Left = 8
AnchorSideLeft.Control = grpScope
AnchorSideTop.Control = grpScope
Left = 6
Height = 24
Top = 0
Top = 6
Width = 98
BorderSpacing.Around = 6
Caption = 'This session'
TabOrder = 0
end
object radioScopeGlobal: TRadioButton
Left = 140
AnchorSideLeft.Control = radioScopeSession
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = grpScope
Left = 110
Height = 24
Top = 0
Top = 6
Width = 65
BorderSpacing.Around = 6
Caption = 'Global'
TabOrder = 1
end
end
object gbValue: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 10
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 164
Top = 6
Width = 344
Width = 352
Align = alTop
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'name of variable'
ClientHeight = 139
ClientWidth = 340
ClientWidth = 348
ParentBackground = False
TabOrder = 3
object lblString: TLabel
Left = 10
AnchorSideLeft.Control = gbValue
AnchorSideTop.Control = gbValue
Left = 6
Height = 20
Top = 8
Top = 6
Width = 42
BorderSpacing.Around = 6
Caption = 'String:'
end
object lblNumber: TLabel
AnchorSideLeft.Control = gbValue
AnchorSideTop.Control = editString
AnchorSideTop.Side = asrBottom
Left = 10
Left = 6
Height = 20
Top = 39
Top = 40
Width = 57
BorderSpacing.Around = 6
Caption = 'Number:'
end
object lblEnum: TLabel
AnchorSideLeft.Control = gbValue
AnchorSideTop.Control = editNumber
AnchorSideTop.Side = asrBottom
Left = 10
Left = 6
Height = 20
Top = 73
Top = 74
Width = 87
BorderSpacing.Around = 6
Caption = 'Enumeration:'
@ -114,19 +143,20 @@ object frmEditVariable: TfrmEditVariable
object lblBoolean: TLabel
AnchorSideTop.Control = comboEnum
AnchorSideTop.Side = asrBottom
Left = 10
Left = 6
Height = 20
Top = 107
Top = 108
Width = 58
BorderSpacing.Around = 6
Caption = 'Boolean:'
end
object radioBooleanOn: TRadioButton
AnchorSideLeft.Control = comboEnum
AnchorSideTop.Control = comboEnum
AnchorSideTop.Side = asrBottom
Left = 110
Left = 112
Height = 24
Top = 107
Top = 108
Width = 40
BorderSpacing.Around = 6
Caption = 'On'
@ -135,10 +165,10 @@ object frmEditVariable: TfrmEditVariable
object radioBooleanOff: TRadioButton
AnchorSideTop.Control = comboEnum
AnchorSideTop.Side = asrBottom
Left = 220
Left = 216
Height = 24
Top = 107
Width = 110
Top = 108
Width = 122
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
Caption = 'Off'
@ -147,10 +177,12 @@ object frmEditVariable: TfrmEditVariable
object comboEnum: TComboBox
AnchorSideTop.Control = editNumber
AnchorSideTop.Side = asrBottom
Left = 110
AnchorSideRight.Control = gbValue
AnchorSideRight.Side = asrBottom
Left = 106
Height = 28
Top = 73
Width = 221
Top = 74
Width = 236
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
ItemHeight = 20
@ -160,10 +192,12 @@ object frmEditVariable: TfrmEditVariable
object editNumber: TEdit
AnchorSideTop.Control = editString
AnchorSideTop.Side = asrBottom
Left = 110
AnchorSideRight.Control = gbValue
AnchorSideRight.Side = asrBottom
Left = 106
Height = 28
Top = 39
Width = 221
Top = 40
Width = 236
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
NumbersOnly = True
@ -171,19 +205,25 @@ object frmEditVariable: TfrmEditVariable
Text = '0'
end
object editString: TEdit
Left = 110
AnchorSideTop.Control = gbValue
AnchorSideRight.Control = gbValue
AnchorSideRight.Side = asrBottom
Left = 106
Height = 28
Top = 5
Width = 221
Top = 6
Width = 236
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
TabOrder = 4
end
end
object btnHelp: TButton
Left = 58
AnchorSideRight.Control = btnOK
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 64
Height = 31
Top = 237
Top = 241
Width = 94
Anchors = [akRight, akBottom]
BorderSpacing.Around = 6

View File

@ -1101,7 +1101,6 @@ object MainForm: TMainForm
OnCloseTabClicked = PageControlMainCloseTabClicked
OnContextPopup = PageControlMainContextPopup
OnMouseUp = PageControlMainMouseUp
Options = [nboShowCloseButtons, nboShowAddTabButton]
object tabHost: TTabSheet
Caption = 'Host'
ClientHeight = 282

View File

@ -90,7 +90,7 @@ type
Number: Integer;
Uid: String;
ExecutionThread: TQueryThread;
CloseButton: TSpeedButton;
//CloseButton: TSpeedButton;
pnlMemo: TPanel;
Memo: TSynMemo;
pnlHelpers: TPanel;
@ -987,8 +987,8 @@ type
procedure actCloseQueryTabExecute(Sender: TObject);
procedure menuCloseQueryTabClick(Sender: TObject);
procedure CloseQueryTab(PageIndex: Integer);
//procedure CloseButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
//procedure CloseButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure CloseButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure CloseButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
function GetMainTabAt(X, Y: Integer): Integer;
procedure FixQueryTabCloseButtons;
function GetOrCreateEmptyQueryTab(DoFocus: Boolean): TQueryTab;
@ -2108,7 +2108,7 @@ begin
// We already store and restore the dimensions DPI aware.
{SynCompletionProposal.Form.Scaled := False;
SynCompletionProposal.TimerInterval := AppSettings.ReadInt(asCompletionProposalInterval);}
SynCompletionProposal.Width := AppSettings.ReadInt(asCompletionProposalWidth);
SynCompletionProposal.Width := Min(AppSettings.ReadInt(asCompletionProposalWidth), 1000);
SynCompletionProposal.LinesInWindow := AppSettings.ReadInt(asCompletionProposalNbLinesInWindow);
// Place progressbar on the statusbar
@ -2824,7 +2824,7 @@ begin
ProgressBarStatus.Width := StatusBar.Panels[5].Width;
//lblDataTop.Width := pnlDataTop.Width - tlbDataButtons.Width - 10;
{FixQueryTabCloseButtons;}
FixQueryTabCloseButtons;
// Right aligned button
// Do not set ToolBar.Align to alRight. See issue #1967
@ -12293,14 +12293,14 @@ begin
QueryTab.TabSheet.PageControl := PageControlMain;
QueryTab.TabSheet.ImageIndex := tabQuery.ImageIndex;
QueryTab.CloseButton := TSpeedButton.Create(QueryTab.TabSheet);
{QueryTab.CloseButton := TSpeedButton.Create(QueryTab.TabSheet);
QueryTab.CloseButton.Parent := PageControlMain;
QueryTab.CloseButton.Width := 16;
QueryTab.CloseButton.Height := 16;
QueryTab.CloseButton.Flat := True;
VirtualImageListMain.GetBitmap(134, QueryTab.CloseButton.Glyph);
//QueryTab.CloseButton.OnMouseDown := CloseButtonOnMouseDown;
//QueryTab.CloseButton.OnMouseUp := CloseButtonOnMouseUp;
QueryTab.CloseButton.OnMouseDown := CloseButtonOnMouseDown;
QueryTab.CloseButton.OnMouseUp := CloseButtonOnMouseUp;}
SetTabCaption(QueryTab.TabSheet.PageIndex, '');
// Dumb code which replicates all controls from tabQuery
@ -12850,13 +12850,13 @@ begin
end;
{procedure TMainForm.CloseButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure TMainForm.CloseButtonOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FLastMouseDownCloseButton := Sender;
end;}
end;
{procedure TMainForm.CloseButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure TMainForm.CloseButtonOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
// Click on "Close" button of Query tab
if Button <> mbLeft then
@ -12867,12 +12867,12 @@ begin
Exit;
// Prevent EAccessViolation in TControl.GetClientWidth, see issue #1640
TimerCloseTabByButton.Enabled := True;
end;}
end;
procedure TMainForm.PageControlMainCloseTabClicked(Sender: TObject);
begin
logsql('PageControlMainCloseTabClicked');
//TimerCloseTabByButton.Enabled := True;
TimerCloseTabByButton.Enabled := True;
end;
@ -12883,10 +12883,10 @@ begin
// Asynchronous timer for mousedown event on query tab close button
TimerCloseTabByButton.Enabled := False;
for i:=0 to QueryTabs.Count-1 do begin
if QueryTabs[i].CloseButton = FLastMouseDownCloseButton then begin
{if QueryTabs[i].CloseButton = FLastMouseDownCloseButton then begin
CloseQueryTab(QueryTabs[i].TabSheet.PageIndex);
break;
end;
end;}
end;
end;