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 diff
     1.1 --- a/FrmArmyTree.cs	Mon Sep 07 20:10:40 2009 +0000
     1.2 +++ b/FrmArmyTree.cs	Wed Sep 09 19:37:14 2009 +0000
     1.3 @@ -139,8 +139,11 @@
     1.4  		{
     1.5  			htNodes.Clear();
     1.6  			treeView.Nodes.Clear();
     1.7 +			ICollection unitFormsCollection = htUnitWindows.Values;
     1.8 +			FrmUnit[] unitForms = new FrmUnit[unitFormsCollection.Count];
     1.9 +			unitFormsCollection.CopyTo(unitForms, 0);
    1.10  
    1.11 -			foreach (FrmUnit window in htUnitWindows.Values)
    1.12 +			foreach (FrmUnit window in unitForms)
    1.13  			{
    1.14  				window.Close();
    1.15  			}