mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Experimental: Remove TDBConnection.OnDBObjectsCleared, which was used to implicitly refresh db items and tree nodes after items were cleared somewhere. Callers already did a refresh in some cases, which lead to duplicated "SHOW xyz FROM db" blocks. This again caused the "Database" tab to forget its scroll position within refreshes. Should fix issue #3409.
This commit is contained in:
@@ -257,7 +257,6 @@ type
|
||||
FOnLog: TDBLogEvent;
|
||||
FOnConnected: TDBEvent;
|
||||
FOnDatabaseChanged: TDBEvent;
|
||||
FOnDBObjectsCleared: TDBEvent;
|
||||
FRowsFound: Int64;
|
||||
FRowsAffected: Int64;
|
||||
FWarningCount: Cardinal;
|
||||
@@ -389,7 +388,6 @@ type
|
||||
property OnLog: TDBLogEvent read FOnLog write FOnLog;
|
||||
property OnConnected: TDBEvent read FOnConnected write FOnConnected;
|
||||
property OnDatabaseChanged: TDBEvent read FOnDatabaseChanged write FOnDatabaseChanged;
|
||||
property OnDBObjectsCleared: TDBEvent read FOnDBObjectsCleared write FOnDBObjectsCleared;
|
||||
end;
|
||||
TDBConnectionList = TObjectList<TDBConnection>;
|
||||
|
||||
@@ -959,7 +957,6 @@ end;
|
||||
destructor TDBConnection.Destroy;
|
||||
begin
|
||||
if Active then Active := False;
|
||||
FOnDBObjectsCleared := nil;
|
||||
ClearCache(True);
|
||||
FKeepAliveTimer.Free;
|
||||
FFavorites.Free;
|
||||
@@ -2840,15 +2837,11 @@ end;
|
||||
procedure TDBConnection.ClearDbObjects(db: String);
|
||||
var
|
||||
i: Integer;
|
||||
TriggerClearEvent: Boolean;
|
||||
begin
|
||||
// Free cached database object list
|
||||
for i:=FDatabaseCache.Count-1 downto 0 do begin
|
||||
if FDatabaseCache[i].Database = db then begin
|
||||
TriggerClearEvent := FDatabaseCache[i].OnlyNodeType=lntNone;
|
||||
FDatabaseCache.Delete(i);
|
||||
if TriggerClearEvent and Assigned(FOnDBObjectsCleared) then
|
||||
FOnDBObjectsCleared(Self, db);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -995,7 +995,6 @@ type
|
||||
function ConfirmTabClose(PageIndex: Integer): Boolean;
|
||||
procedure UpdateFilterPanel(Sender: TObject);
|
||||
procedure ConnectionReady(Connection: TDBConnection; Database: String);
|
||||
procedure DBObjectsCleared(Connection: TDBConnection; Database: String);
|
||||
procedure DatabaseChanged(Connection: TDBConnection; Database: String);
|
||||
procedure UpdateLineCharPanel;
|
||||
procedure SetSnippetFilenames;
|
||||
@@ -3013,6 +3012,7 @@ begin
|
||||
Conn.Query('SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS');
|
||||
// Refresh ListTables + dbtree so the dropped tables are gone:
|
||||
Conn.ClearDbObjects(ActiveDatabase);
|
||||
RefreshTree;
|
||||
SetActiveDatabase(Conn.Database, Conn);
|
||||
except
|
||||
on E:EDatabaseError do
|
||||
@@ -3397,7 +3397,6 @@ begin
|
||||
Connection := Params.CreateConnection(Self);
|
||||
Connection.OnLog := LogSQL;
|
||||
Connection.OnConnected := ConnectionReady;
|
||||
Connection.OnDBObjectsCleared := DBObjectsCleared;
|
||||
Connection.OnDatabaseChanged := DatabaseChanged;
|
||||
Connection.ObjectNamesInSelectedDB := SynSQLSyn1.TableNames;
|
||||
try
|
||||
@@ -7738,36 +7737,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.DBObjectsCleared(Connection: TDBConnection; Database: String);
|
||||
var
|
||||
Node: PVirtualNode;
|
||||
WasExpanded: Boolean;
|
||||
begin
|
||||
// Avoid AVs while processing FormDestroy
|
||||
if csDestroying in ComponentState then
|
||||
Exit;
|
||||
// Reload objects in ListTables ...
|
||||
InvalidateVT(ListTables, VTREE_NOTLOADED, False);
|
||||
// ... and in database tree
|
||||
Node := FindDBNode(DBTree, Connection, Database);
|
||||
if Assigned(Node) then begin
|
||||
WasExpanded := DBTree.Expanded[Node];
|
||||
// Will trigger OnFocusChanged:
|
||||
DBTree.ResetNode(Node);
|
||||
DBtree.Expanded[Node] := WasExpanded;
|
||||
{
|
||||
// Earlier code, replaced by above ResetNode, not sure if that causes new errors.
|
||||
// See issue #2645
|
||||
Tree.ReinitNode(Node, False);
|
||||
if Tree.Expanded[Node] then
|
||||
Tree.ReinitChildren(Node, False)
|
||||
else
|
||||
Tree.ResetNode(Node);
|
||||
}
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.DatabaseChanged(Connection: TDBConnection; Database: String);
|
||||
begin
|
||||
// Immediately force db icons to repaint, so the user sees the active db state
|
||||
|
||||
Reference in New Issue
Block a user