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 OnMessageHandler(var Msg: TMsg; var Handled: Boolean);
|
||||||
procedure DefaultHandler(var Message); override;
|
procedure DefaultHandler(var Message); override;
|
||||||
procedure SetupSynEditors;
|
procedure SetupSynEditors;
|
||||||
procedure ParseSelectedTableStructure;
|
|
||||||
function AnyGridEnsureFullRow(Grid: TVirtualStringTree; Node: PVirtualNode): Boolean;
|
function AnyGridEnsureFullRow(Grid: TVirtualStringTree; Node: PVirtualNode): Boolean;
|
||||||
procedure DataGridEnsureFullRows(Grid: TVirtualStringTree; SelectedOnly: Boolean);
|
procedure DataGridEnsureFullRows(Grid: TVirtualStringTree; SelectedOnly: Boolean);
|
||||||
function GetEncodingByName(Name: String): TEncoding;
|
function GetEncodingByName(Name: String): TEncoding;
|
||||||
@ -4058,6 +4057,7 @@ begin
|
|||||||
if DBObj = nil then
|
if DBObj = nil then
|
||||||
Exit;
|
Exit;
|
||||||
Screen.Cursor := crHourglass;
|
Screen.Cursor := crHourglass;
|
||||||
|
DBObj.Connection.Ping(True);
|
||||||
|
|
||||||
// No data for routines
|
// No data for routines
|
||||||
if SelectedTableColumns.Count = 0 then begin
|
if SelectedTableColumns.Count = 0 then begin
|
||||||
@ -6785,6 +6785,7 @@ procedure TMainForm.DBtreeFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualN
|
|||||||
var
|
var
|
||||||
DBObj, PrevDBObj: PDBObject;
|
DBObj, PrevDBObj: PDBObject;
|
||||||
MainTabToActivate: TTabSheet;
|
MainTabToActivate: TTabSheet;
|
||||||
|
DummyStr: String;
|
||||||
begin
|
begin
|
||||||
// Set wanted main tab and call SetMainTab later, when all lists have been invalidated
|
// Set wanted main tab and call SetMainTab later, when all lists have been invalidated
|
||||||
MainTabToActivate := nil;
|
MainTabToActivate := nil;
|
||||||
@ -6828,7 +6829,23 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
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
|
if not FTreeRefreshInProgress then
|
||||||
PlaceObjectEditor(FActiveDbObj);
|
PlaceObjectEditor(FActiveDbObj);
|
||||||
// When a table is clicked in the tree, and the current
|
// When a table is clicked in the tree, and the current
|
||||||
@ -6953,27 +6970,6 @@ begin
|
|||||||
end;
|
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);
|
procedure TMainForm.ConnectionReady(Connection: TDBConnection; Database: String);
|
||||||
begin
|
begin
|
||||||
// Manually trigger changed focused tree node, to display the right server vendor
|
// Manually trigger changed focused tree node, to display the right server vendor
|
||||||
|
@ -399,7 +399,6 @@ begin
|
|||||||
tabALTERcode.TabVisible := DBObject.Name <> '';
|
tabALTERcode.TabVisible := DBObject.Name <> '';
|
||||||
Mainform.UpdateEditorTab;
|
Mainform.UpdateEditorTab;
|
||||||
Mainform.RefreshTree(DBObject);
|
Mainform.RefreshTree(DBObject);
|
||||||
Mainform.ParseSelectedTableStructure;
|
|
||||||
Mainform.RefreshHelperNode(HELPERNODE_COLUMNS);
|
Mainform.RefreshHelperNode(HELPERNODE_COLUMNS);
|
||||||
ResetModificationFlags;
|
ResetModificationFlags;
|
||||||
AlterCodeValid := False;
|
AlterCodeValid := False;
|
||||||
|
@ -178,7 +178,6 @@ begin
|
|||||||
DBObject.CreateCode := '';
|
DBObject.CreateCode := '';
|
||||||
Mainform.UpdateEditorTab;
|
Mainform.UpdateEditorTab;
|
||||||
Mainform.RefreshTree(DBObject);
|
Mainform.RefreshTree(DBObject);
|
||||||
Mainform.ParseSelectedTableStructure;
|
|
||||||
Modified := False;
|
Modified := False;
|
||||||
btnSave.Enabled := Modified;
|
btnSave.Enabled := Modified;
|
||||||
btnDiscard.Enabled := Modified;
|
btnDiscard.Enabled := Modified;
|
||||||
|
Reference in New Issue
Block a user