avoid exception when disposing external tools items

Similar to #114
Thanks @Brandhor
This commit is contained in:
Sean Kaim
2016-05-31 20:53:10 -04:00
parent 1c83609971
commit 99df3df42c

View File

@@ -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();
}