mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Refreshing datagrid result while connection is cut triggers SelectedTableColumns to reset implicitly in ConnectionReady > DBTreeFocusChanged > ParseSelectedTableStructure. Add an explicit Connection.Ping(true) before firing any query in DatagridBeforePaint, and merge code from ParseSelectedTableStructure into DBTreeFocusChanges. Fixes issue #2644.
This commit is contained in:
@ -1015,7 +1015,6 @@ type
|
||||
procedure OnMessageHandler(var Msg: TMsg; var Handled: Boolean);
|
||||
procedure DefaultHandler(var Message); override;
|
||||
procedure SetupSynEditors;
|
||||
procedure ParseSelectedTableStructure;
|
||||
function AnyGridEnsureFullRow(Grid: TVirtualStringTree; Node: PVirtualNode): Boolean;
|
||||
procedure DataGridEnsureFullRows(Grid: TVirtualStringTree; SelectedOnly: Boolean);
|
||||
function GetEncodingByName(Name: String): TEncoding;
|
||||
@ -4058,6 +4057,7 @@ begin
|
||||
if DBObj = nil then
|
||||
Exit;
|
||||
Screen.Cursor := crHourglass;
|
||||
DBObj.Connection.Ping(True);
|
||||
|
||||
// No data for routines
|
||||
if SelectedTableColumns.Count = 0 then begin
|
||||
@ -6785,6 +6785,7 @@ procedure TMainForm.DBtreeFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualN
|
||||
var
|
||||
DBObj, PrevDBObj: PDBObject;
|
||||
MainTabToActivate: TTabSheet;
|
||||
DummyStr: String;
|
||||
begin
|
||||
// Set wanted main tab and call SetMainTab later, when all lists have been invalidated
|
||||
MainTabToActivate := nil;
|
||||
@ -6828,7 +6829,23 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
ParseSelectedTableStructure;
|
||||
|
||||
// Retrieve columns of current table or view. Mainly used in datagrid.
|
||||
SelectedTableColumns.Clear;
|
||||
SelectedTableKeys.Clear;
|
||||
SelectedTableForeignKeys.Clear;
|
||||
InvalidateVT(DataGrid, VTREE_NOTLOADED_PURGECACHE, False);
|
||||
try
|
||||
case FActiveDbObj.NodeType of
|
||||
lntTable:
|
||||
FActiveDbObj.Connection.ParseTableStructure(FActiveDbObj.CreateCode, SelectedTableColumns, SelectedTableKeys, SelectedTableForeignKeys);
|
||||
lntView:
|
||||
FActiveDbObj.Connection.ParseViewStructure(FActiveDbObj.CreateCode, FActiveDbObj.Name, SelectedTableColumns, DummyStr, DummyStr, DummyStr, DummyStr);
|
||||
end;
|
||||
except on E:EDatabaseError do
|
||||
ErrorDialog(E.Message);
|
||||
end;
|
||||
|
||||
if not FTreeRefreshInProgress then
|
||||
PlaceObjectEditor(FActiveDbObj);
|
||||
// When a table is clicked in the tree, and the current
|
||||
@ -6953,27 +6970,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.ParseSelectedTableStructure;
|
||||
var
|
||||
DummyStr: String;
|
||||
begin
|
||||
SelectedTableColumns.Clear;
|
||||
SelectedTableKeys.Clear;
|
||||
SelectedTableForeignKeys.Clear;
|
||||
InvalidateVT(DataGrid, VTREE_NOTLOADED_PURGECACHE, False);
|
||||
try
|
||||
case ActiveDbObj.NodeType of
|
||||
lntTable:
|
||||
ActiveConnection.ParseTableStructure(ActiveDbObj.CreateCode, SelectedTableColumns, SelectedTableKeys, SelectedTableForeignKeys);
|
||||
lntView:
|
||||
ActiveConnection.ParseViewStructure(ActiveDbObj.CreateCode, ActiveDbObj.Name, SelectedTableColumns, DummyStr, DummyStr, DummyStr, DummyStr);
|
||||
end;
|
||||
except on E:EDatabaseError do
|
||||
ErrorDialog(E.Message);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.ConnectionReady(Connection: TDBConnection; Database: String);
|
||||
begin
|
||||
// Manually trigger changed focused tree node, to display the right server vendor
|
||||
|
@ -399,7 +399,6 @@ begin
|
||||
tabALTERcode.TabVisible := DBObject.Name <> '';
|
||||
Mainform.UpdateEditorTab;
|
||||
Mainform.RefreshTree(DBObject);
|
||||
Mainform.ParseSelectedTableStructure;
|
||||
Mainform.RefreshHelperNode(HELPERNODE_COLUMNS);
|
||||
ResetModificationFlags;
|
||||
AlterCodeValid := False;
|
||||
|
@ -178,7 +178,6 @@ begin
|
||||
DBObject.CreateCode := '';
|
||||
Mainform.UpdateEditorTab;
|
||||
Mainform.RefreshTree(DBObject);
|
||||
Mainform.ParseSelectedTableStructure;
|
||||
Modified := False;
|
||||
btnSave.Enabled := Modified;
|
||||
btnDiscard.Enabled := Modified;
|
||||
|
Reference in New Issue
Block a user