From a71cf6080f87bc4f96da4b7f485f7f145ec9a52a Mon Sep 17 00:00:00 2001 From: David Sparer Date: Thu, 29 Sep 2016 11:01:06 -0600 Subject: [PATCH] Fixed bug where loading a new connection file or creating a new one would not update the connection tree --- mRemoteV1/App/Runtime.cs | 11 +++++------ mRemoteV1/Config/Connections/ConnectionsLoader.cs | 10 ++++++---- mRemoteV1/UI/Forms/frmMain.cs | 1 - 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mRemoteV1/App/Runtime.cs b/mRemoteV1/App/Runtime.cs index 597691eff..5feafca4f 100644 --- a/mRemoteV1/App/Runtime.cs +++ b/mRemoteV1/App/Runtime.cs @@ -228,12 +228,10 @@ namespace mRemoteNG.App } - var rootConnectionNode = ConnectionTreeModel.RootNodes.First(node => !(node is RootPuttySessionsNodeInfo)); - ConnectionTreeModel.RemoveRootNode(rootConnectionNode); - // Load config connectionsLoader.ConnectionFileName = filename; - connectionsLoader.LoadConnections(false); + ConnectionTreeModel = connectionsLoader.LoadConnections(false); + Windows.TreeForm.ConnectionTreeModel = ConnectionTreeModel; } catch (Exception ex) { @@ -270,7 +268,7 @@ namespace mRemoteNG.App { if (withDialog) { - var loadDialog = Tools.Controls.ConnectionsLoadDialog(); + var loadDialog = Controls.ConnectionsLoadDialog(); if (loadDialog.ShowDialog() != DialogResult.OK) return; connectionsLoader.ConnectionFileName = loadDialog.FileName; } @@ -283,7 +281,8 @@ namespace mRemoteNG.App } connectionsLoader.UseDatabase = Settings.Default.UseSQLServer; - connectionsLoader.LoadConnections(false); + ConnectionTreeModel = connectionsLoader.LoadConnections(false); + Windows.TreeForm.ConnectionTreeModel = ConnectionTreeModel; if (Settings.Default.UseSQLServer) { diff --git a/mRemoteV1/Config/Connections/ConnectionsLoader.cs b/mRemoteV1/Config/Connections/ConnectionsLoader.cs index a7540255f..af7c54dc0 100644 --- a/mRemoteV1/Config/Connections/ConnectionsLoader.cs +++ b/mRemoteV1/Config/Connections/ConnectionsLoader.cs @@ -3,6 +3,7 @@ using mRemoteNG.Config.DatabaseConnectors; using mRemoteNG.Config.DataProviders; using mRemoteNG.Config.Putty; using mRemoteNG.Config.Serializers; +using mRemoteNG.Tree; using mRemoteNG.UI.Forms; @@ -14,7 +15,7 @@ namespace mRemoteNG.Config.Connections public string ConnectionFileName { get; set; } - public void LoadConnections(bool import) + public ConnectionTreeModel LoadConnections(bool import) { IDeserializer deserializer; if (UseDatabase) @@ -32,14 +33,15 @@ namespace mRemoteNG.Config.Connections } var connectionTreeModel = deserializer.Deserialize(); - Runtime.ConnectionTreeModel = connectionTreeModel; frmMain.Default.AreWeUsingSqlServerForSavingConnections = UseDatabase; frmMain.Default.ConnectionsFileName = ConnectionFileName; - if (import) return; + if (import) return connectionTreeModel; PuttySessionsManager.Instance.AddSessions(); - Runtime.ConnectionTreeModel.RootNodes.AddRange(PuttySessionsManager.Instance.RootPuttySessionsNodes); + connectionTreeModel.RootNodes.AddRange(PuttySessionsManager.Instance.RootPuttySessionsNodes); + + return connectionTreeModel; } } } \ No newline at end of file diff --git a/mRemoteV1/UI/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs index 50662b641..e6d8fab66 100644 --- a/mRemoteV1/UI/Forms/frmMain.cs +++ b/mRemoteV1/UI/Forms/frmMain.cs @@ -171,7 +171,6 @@ namespace mRemoteNG.UI.Forms Opacity = 1; ConnectionTreeWindow = Windows.TreeForm; - ConnectionTreeWindow.ConnectionTreeModel = Runtime.ConnectionTreeModel; } private void ApplySpecialSettingsForPortableVersion()