mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Merge pull request #149 from mRemoteNG/Hunting_for_memory_leaks
Hunting for memory leaks
This commit is contained in:
@@ -70,10 +70,7 @@ namespace mRemoteNG.Config.Connections
|
||||
public event UpdateCheckFinishedEventHandler UpdateCheckFinished;
|
||||
public event ConnectionsUpdateAvailableEventHandler ConnectionsUpdateAvailable;
|
||||
|
||||
~RemoteConnectionsSyncronizer()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
@@ -101,12 +101,6 @@ namespace mRemoteNG.Config.Connections
|
||||
_lastUpdateTime = _lastDatabaseUpdateTime;
|
||||
}
|
||||
|
||||
|
||||
~SqlConnectionsUpdateChecker()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
@@ -14,11 +14,6 @@ namespace mRemoteNG.Config.DataProviders
|
||||
SqlDatabaseConnector = sqlDatabaseConnector;
|
||||
}
|
||||
|
||||
~SqlDataProvider()
|
||||
{
|
||||
SqlDatabaseConnector.Dispose();
|
||||
}
|
||||
|
||||
public DataTable Load()
|
||||
{
|
||||
var dataTable = new DataTable();
|
||||
|
||||
@@ -21,11 +21,6 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
Initialize();
|
||||
}
|
||||
|
||||
~SqlDatabaseConnector()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
BuildSqlConnectionString();
|
||||
|
||||
@@ -110,7 +110,6 @@ namespace mRemoteNG.Config.Putty
|
||||
if (_eventWatcher == null) return;
|
||||
_eventWatcher.Stop();
|
||||
_eventWatcher.Dispose();
|
||||
_eventWatcher = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -162,7 +162,6 @@ namespace mRemoteNG.Config.Putty
|
||||
}
|
||||
_eventWatcher.EnableRaisingEvents = false;
|
||||
_eventWatcher.Dispose();
|
||||
_eventWatcher = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ using mRemoteNG.Tree;
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
[DefaultProperty("Name")]
|
||||
public class ConnectionInfo : AbstractConnectionInfoData, IHasParent, IInheritable, IDisposable
|
||||
public class ConnectionInfo : AbstractConnectionInfoData, IHasParent, IInheritable
|
||||
{
|
||||
#region Public Properties
|
||||
[Browsable(false)]
|
||||
@@ -137,11 +137,6 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
Parent?.RemoveChild(this);
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
RemoveParent();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Enumerations
|
||||
|
||||
@@ -173,14 +173,6 @@ namespace mRemoteNG.Container
|
||||
SortOn(propertyToCompare, sortDirection);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
var tempChildList = Children.ToArray();
|
||||
foreach (var child in tempChildList)
|
||||
child.Dispose();
|
||||
RemoveParent();
|
||||
}
|
||||
|
||||
// Deep clone, recursive
|
||||
public override ConnectionInfo Clone()
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace mRemoteNG.Tree
|
||||
if (connectionInfo is RootNodeInfo)
|
||||
return;
|
||||
|
||||
connectionInfo?.Dispose();
|
||||
connectionInfo?.RemoveParent();
|
||||
}
|
||||
|
||||
public void CloneNode(ConnectionInfo connectionInfo)
|
||||
|
||||
@@ -222,21 +222,34 @@ namespace mRemoteNG.UI.Window
|
||||
|
||||
private void PopulateTreeView()
|
||||
{
|
||||
UnregisterModelUpdateHandlers();
|
||||
olvConnections.SetObjects(ConnectionTreeModel.RootNodes);
|
||||
SetModelUpdateHandlers();
|
||||
RegisterModelUpdateHandlers();
|
||||
_nodeSearcher = new NodeSearcher(ConnectionTreeModel);
|
||||
ExpandPreviouslyOpenedFolders();
|
||||
ExpandRootConnectionNode();
|
||||
OpenConnectionsFromLastSession();
|
||||
}
|
||||
|
||||
private void SetModelUpdateHandlers()
|
||||
private void RegisterModelUpdateHandlers()
|
||||
{
|
||||
_puttySessionsManager.PuttySessionsCollectionChanged += (sender, args) => RefreshTreeObjects(GetRootPuttyNodes().ToList());
|
||||
_puttySessionsManager.PuttySessionsCollectionChanged += OnPuttySessionsCollectionChanged;
|
||||
ConnectionTreeModel.CollectionChanged += HandleCollectionChanged;
|
||||
ConnectionTreeModel.PropertyChanged += HandleCollectionPropertyChanged;
|
||||
}
|
||||
|
||||
private void UnregisterModelUpdateHandlers()
|
||||
{
|
||||
_puttySessionsManager.PuttySessionsCollectionChanged -= OnPuttySessionsCollectionChanged;
|
||||
ConnectionTreeModel.CollectionChanged -= HandleCollectionChanged;
|
||||
ConnectionTreeModel.PropertyChanged -= HandleCollectionPropertyChanged;
|
||||
}
|
||||
|
||||
private void OnPuttySessionsCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
RefreshTreeObjects(GetRootPuttyNodes().ToList());
|
||||
}
|
||||
|
||||
private void HandleCollectionPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
|
||||
{
|
||||
//TODO for some reason property changed events are getting triggered twice for each changed property. should be just once. cant find source of duplication
|
||||
|
||||
Reference in New Issue
Block a user