From 99df3df42c84af97a1f5adda86113be175ec4c80 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Tue, 31 May 2016 20:53:10 -0400 Subject: [PATCH] avoid exception when disposing external tools items Similar to #114 Thanks @Brandhor --- mRemoteV1/UI/Window/ConnectionWindow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mRemoteV1/UI/Window/ConnectionWindow.cs b/mRemoteV1/UI/Window/ConnectionWindow.cs index 7611199b..cfb315f9 100644 --- a/mRemoteV1/UI/Window/ConnectionWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionWindow.cs @@ -973,8 +973,8 @@ namespace mRemoteNG.UI.Window //since new items are added below, we have to dispose of any previous items first if (cmenTabExternalApps.DropDownItems.Count > 0) { - foreach (ToolStripMenuItem mitem in cmenTabExternalApps.DropDownItems) - mitem.Dispose(); + for (int i = cmenTabExternalApps.DropDownItems.Count - 1; i >= 0; i--) + cmenTabExternalApps.DropDownItems[i].Dispose(); cmenTabExternalApps.DropDownItems.Clear(); }