mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Try to fix dbtree focus/refresh access violation. Fixes issue #2665.
This commit is contained in:
@ -3317,6 +3317,7 @@ procedure TMainForm.actRefreshExecute(Sender: TObject);
|
|||||||
var
|
var
|
||||||
tab1, tab2: TTabSheet;
|
tab1, tab2: TTabSheet;
|
||||||
List: TVirtualStringTree;
|
List: TVirtualStringTree;
|
||||||
|
OldDbObject: TDBObject;
|
||||||
begin
|
begin
|
||||||
// Refresh
|
// Refresh
|
||||||
// Force data tab update when appropriate.
|
// Force data tab update when appropriate.
|
||||||
@ -3336,9 +3337,11 @@ begin
|
|||||||
else
|
else
|
||||||
List := ListCommandStats;
|
List := ListCommandStats;
|
||||||
InvalidateVT(List, VTREE_NOTLOADED_PURGECACHE, True);
|
InvalidateVT(List, VTREE_NOTLOADED_PURGECACHE, True);
|
||||||
end else if tab1 = tabDatabase then
|
end else if tab1 = tabDatabase then begin
|
||||||
InvalidateVT(ListTables, VTREE_NOTLOADED_PURGECACHE, False)
|
OldDbObject := TDBObject.Create(FActiveDbObj.Connection);
|
||||||
else if tab1 = tabData then
|
OldDbObject.Assign(FActiveDbObj);
|
||||||
|
RefreshTree(OldDbObject);
|
||||||
|
end else if tab1 = tabData then
|
||||||
InvalidateVT(DataGrid, VTREE_NOTLOADED_PURGECACHE, False);
|
InvalidateVT(DataGrid, VTREE_NOTLOADED_PURGECACHE, False);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5964,7 +5967,10 @@ begin
|
|||||||
Conn := ActiveConnection;
|
Conn := ActiveConnection;
|
||||||
while Assigned(Node) do begin
|
while Assigned(Node) do begin
|
||||||
db := ListDatabases.Text[Node, 0];
|
db := ListDatabases.Text[Node, 0];
|
||||||
Conn.GetDBObjects(db, True);
|
if db = ActiveDatabase then
|
||||||
|
RefreshTree
|
||||||
|
else
|
||||||
|
Conn.GetDBObjects(db, True);
|
||||||
ListDatabases.RepaintNode(Node);
|
ListDatabases.RepaintNode(Node);
|
||||||
DBtree.RepaintNode(FindDBNode(DBtree, Conn, db));
|
DBtree.RepaintNode(FindDBNode(DBtree, Conn, db));
|
||||||
Node := GetNextNode(ListDatabases, Node, True);
|
Node := GetNextNode(ListDatabases, Node, True);
|
||||||
@ -7031,6 +7037,7 @@ begin
|
|||||||
Node := FindDBNode(DBTree, Connection, Database);
|
Node := FindDBNode(DBTree, Connection, Database);
|
||||||
if Assigned(Node) then begin
|
if Assigned(Node) then begin
|
||||||
WasExpanded := DBTree.Expanded[Node];
|
WasExpanded := DBTree.Expanded[Node];
|
||||||
|
// Will trigger OnFocusChanged:
|
||||||
DBTree.ResetNode(Node);
|
DBTree.ResetNode(Node);
|
||||||
DBtree.Expanded[Node] := WasExpanded;
|
DBtree.Expanded[Node] := WasExpanded;
|
||||||
{
|
{
|
||||||
@ -7107,7 +7114,7 @@ begin
|
|||||||
|
|
||||||
// ReInit tree population
|
// ReInit tree population
|
||||||
FTreeRefreshInProgress := True;
|
FTreeRefreshInProgress := True;
|
||||||
DBtree.FocusedNode := nil;
|
SelectNode(DBtree, nil);
|
||||||
try
|
try
|
||||||
if not OnlyDBNode then begin
|
if not OnlyDBNode then begin
|
||||||
FocusNewObject.Connection.ClearAllDbObjects;
|
FocusNewObject.Connection.ClearAllDbObjects;
|
||||||
@ -7982,8 +7989,12 @@ begin
|
|||||||
if Conn <> nil then begin
|
if Conn <> nil then begin
|
||||||
if vt.Tag = VTREE_NOTLOADED_PURGECACHE then begin
|
if vt.Tag = VTREE_NOTLOADED_PURGECACHE then begin
|
||||||
for i:=0 to Conn.AllDatabases.Count-1 do begin
|
for i:=0 to Conn.AllDatabases.Count-1 do begin
|
||||||
if Conn.DbObjectsCached(Conn.AllDatabases[i]) then
|
if Conn.DbObjectsCached(Conn.AllDatabases[i]) then begin
|
||||||
Conn.GetDBObjects(Conn.AllDatabases[i], True);
|
if Conn.AllDatabases[i] = ActiveDatabase then
|
||||||
|
RefreshTree
|
||||||
|
else
|
||||||
|
Conn.GetDBObjects(Conn.AllDatabases[i], True);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
vt.RootNodeCount := Conn.AllDatabases.Count;
|
vt.RootNodeCount := Conn.AllDatabases.Count;
|
||||||
@ -8105,7 +8116,7 @@ begin
|
|||||||
if vt.Tag = VTREE_LOADED then
|
if vt.Tag = VTREE_LOADED then
|
||||||
Exit;
|
Exit;
|
||||||
Tab := vt.Parent as TTabSheet;
|
Tab := vt.Parent as TTabSheet;
|
||||||
vt.FocusedNode := nil;
|
SelectNode(vt, nil);
|
||||||
vt.BeginUpdate;
|
vt.BeginUpdate;
|
||||||
OldOffset := vt.OffsetXY;
|
OldOffset := vt.OffsetXY;
|
||||||
vt.Clear;
|
vt.Clear;
|
||||||
|
Reference in New Issue
Block a user