From 46497c03e155cae585397babf18bcf02f1216173 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 29 Mar 2012 20:48:03 +0000 Subject: [PATCH] Expand session tree again after creating a new database and refreshing the tree. Fixes issue #2806 --- source/createdatabase.pas | 1 + source/main.pas | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/createdatabase.pas b/source/createdatabase.pas index 4841349e..e1723894 100644 --- a/source/createdatabase.pas +++ b/source/createdatabase.pas @@ -187,6 +187,7 @@ begin if modifyDB = '' then try sql := GetCreateStatement; FConnection.Query(sql); + MainForm.RefreshTree; // Close form ModalResult := mrOK; except diff --git a/source/main.pas b/source/main.pas index b9eb1ac6..0c89ca56 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1967,9 +1967,7 @@ var begin // Create database: Dialog := TCreateDatabaseForm.Create(Self); - // Rely on the modalresult being set correctly - if Dialog.ShowModal = mrOK then - RefreshTree; + Dialog.ShowModal; end; @@ -7358,7 +7356,7 @@ end; procedure TMainForm.RefreshTree(FocusNewObject: TDBObject=nil); var DBNode: PVirtualNode; - OnlyDBNode: Boolean; + OnlyDBNode, Expanded: Boolean; SessNode: PVirtualNode; begin // This refreshes exactly one session node and all its db and table nodes. @@ -7381,8 +7379,11 @@ begin FocusNewObject.Connection.ClearAllDbObjects; FocusNewObject.Connection.RefreshAllDatabases; SessNode := GetRootNode(DBtree, FocusNewObject.Connection); - if Assigned(SessNode) then + if Assigned(SessNode) then begin + Expanded := DBtree.Expanded[SessNode]; DBtree.ResetNode(SessNode); + DBtree.Expanded[SessNode] := Expanded; + end; end else begin FocusNewObject.Connection.ClearDbObjects(FocusNewObject.Database); DBNode := FindDbNode(DBtree, FocusNewObject.Connection, FocusNewObject.Database);