changeset 44:1486ccd744dc

Fixes #135: Closing army crashes WinForms * Simple solution: Cache the open windows as an array then close them from the array to avoid iterating over an collection that gets modified!
author IBBoard <dev@ibboard.co.uk>
date Wed, 09 Sep 2009 19:37:14 +0000
parents 7ace7d2249ac
children 1c74b51abac1
files FrmArmyTree.cs
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/FrmArmyTree.cs	Mon Sep 07 20:10:40 2009 +0000
+++ b/FrmArmyTree.cs	Wed Sep 09 19:37:14 2009 +0000
@@ -139,8 +139,11 @@
 		{
 			htNodes.Clear();
 			treeView.Nodes.Clear();
+			ICollection unitFormsCollection = htUnitWindows.Values;
+			FrmUnit[] unitForms = new FrmUnit[unitFormsCollection.Count];
+			unitFormsCollection.CopyTo(unitForms, 0);
 
-			foreach (FrmUnit window in htUnitWindows.Values)
+			foreach (FrmUnit window in unitForms)
 			{
 				window.Close();
 			}