diff --git a/mRemoteV1/UI/Controls/StatusImageList.cs b/mRemoteV1/UI/Controls/StatusImageList.cs index 4c20e870..9c74b96a 100644 --- a/mRemoteV1/UI/Controls/StatusImageList.cs +++ b/mRemoteV1/UI/Controls/StatusImageList.cs @@ -69,18 +69,15 @@ namespace mRemoteNG.UI.Controls var connected = connection.OpenConnections.Count > 0; var name = BuildConnectionIconName(connection.Icon, connected); - if (!ImageList.Images.ContainsKey(name)) + if (ImageList.Images.ContainsKey(name)) return name; + var image = ConnectionIcon.FromString(connection.Icon); + if (image == null) { - var image = ConnectionIcon.FromString(connection.Icon); - if (image == null) - { - return DefaultConnectionIcon; - } - - ImageList.Images.Add(BuildConnectionIconName(connection.Icon, false), image); - ImageList.Images.Add(BuildConnectionIconName(connection.Icon, true), Overlay(image, Resources.ConnectedOverlay)); - + return DefaultConnectionIcon; } + + ImageList.Images.Add(BuildConnectionIconName(connection.Icon, false), image); + ImageList.Images.Add(BuildConnectionIconName(connection.Icon, true), Overlay(image, Resources.ConnectedOverlay)); return name; } @@ -110,7 +107,16 @@ namespace mRemoteNG.UI.Controls public void Dispose() { - ImageList?.Dispose(); + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + ImageList?.Dispose(); + } } } } \ No newline at end of file