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

View File

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

View File

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