Skip to content

Commit f88405b

Browse files
committed
fix: crash at right-click on data grid header
1 parent 317edcd commit f88405b

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

source/main.lfm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2859,6 +2859,7 @@ object MainForm: TMainForm
28592859
OnBeforePaint = DataGridBeforePaint
28602860
OnChange = AnyGridChange
28612861
OnColumnResize = DataGridColumnResize
2862+
OnContextPopup = DataGridContextPopup
28622863
OnCreateEditor = AnyGridCreateEditor
28632864
OnEditCancelled = AnyGridEditCancelled
28642865
OnEdited = AnyGridEdited

source/main.pas

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ TMainForm = class(TExtForm)
794794
procedure actCreateDBObjectExecute(Sender: TObject);
795795
procedure actNextTabExecute(Sender: TObject);
796796
procedure actPreviousTabExecute(Sender: TObject);
797+
procedure DataGridContextPopup(Sender: TObject; MousePos: TPoint;
798+
var Handled: Boolean);
797799
procedure FormActivate(Sender: TObject);
798800
procedure ImageListGetWidthForPPI(Sender: TCustomImageList;
799801
AImageWidth, APPI: Integer; var AResultWidth: Integer);
@@ -3513,7 +3515,7 @@ procedure TMainForm.actDataPreviewUpdate(Sender: TObject);
35133515
// Enable or disable ImageView action
35143516
Grid := ActiveGrid;
35153517
(Sender as TAction).Enabled := (Grid <> nil)
3516-
and (Grid.FocusedColumn <> NoColumn)
3518+
and (Grid.FocusedColumn-1 <> NoColumn)
35173519
and (GridResult(Grid).DataType(Grid.FocusedColumn-1).Category = dtcBinary)
35183520
end;
35193521

@@ -4327,6 +4329,16 @@ procedure TMainForm.actPreviousTabExecute(Sender: TObject);
43274329
PageControlMain.SelectNextPage(False);
43284330
end;
43294331

4332+
procedure TMainForm.DataGridContextPopup(Sender: TObject; MousePos: TPoint;
4333+
var Handled: Boolean);
4334+
var
4335+
HitInfo: THitInfo;
4336+
begin
4337+
// Prevent context popup if clicked on header, or click was not on a node
4338+
(Sender as TLazVirtualStringTree).GetHitTestInfoAt(MousePos.X, MousePos.Y, True, HitInfo);
4339+
Handled := (HitInfo.HitNode = nil);
4340+
end;
4341+
43304342
procedure TMainForm.FormActivate(Sender: TObject);
43314343
begin
43324344
// Work around non-working wsMaxmized in OnCreate and OnShow
@@ -10398,6 +10410,8 @@ procedure TMainForm.DataGridHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHit
1039810410
// Header click disabled
1039910411
if not AppSettings.ReadBool(asColumnHeaderClick) then
1040010412
Exit;
10413+
if HitInfo.Column = NoColumn then
10414+
Exit;
1040110415
ColName := Sender.Columns[HitInfo.Column].Text;
1040210416
// Add a new order column after a columns title has been clicked
1040310417
// Check if order column is already existant
@@ -13130,7 +13144,7 @@ procedure TMainform.SetupSynEditors;
1313013144
Editors.Add(SynMemoProcessView);
1313113145
Editors.Add(SynMemoSQLLog);
1313213146
if Assigned(ActiveObjectEditor) then
13133-
FindComponentInstances(ActiveObjectEditor, TSynMemo, Editors);
13147+
FindComponentInstances(ActiveObjectEditor, TSynEdit, Editors);
1313413148
if Assigned(frmPreferences) then
1313513149
Editors.Add(frmPreferences.SynMemoSQLSample);
1313613150
if Assigned(FCreateDatabaseDialog) then
@@ -13206,9 +13220,9 @@ procedure TMainForm.SetupSynEditors(BaseForm: TComponent);
1320613220
begin
1320713221
// Restore font, highlighter and shortcuts for all TSynMemo's in given base form
1320813222
Editors := TObjectList<TComponent>.Create(False);
13209-
FindComponentInstances(BaseForm, TSynMemo, Editors);
13223+
FindComponentInstances(BaseForm, TSynEdit, Editors);
1321013224
for i:=0 to Editors.Count-1 do begin
13211-
SetupSynEditor(Editors[i] as TSynMemo);
13225+
SetupSynEditor(Editors[i] as TSynEdit);
1321213226
end;
1321313227
Editors.Free;
1321413228
end;

0 commit comments

Comments
 (0)