Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
changeset 50:c972fb283675
Fixes #149: Crash with edit on null tree item
* Clean up code - can't seem to recreate
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 15 Sep 2009 19:41:41 +0000 |
parents | 93b3d23147ba |
children | 53a18feb2370 |
files | FrmArmyTree.cs |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmArmyTree.cs Mon Sep 14 20:43:52 2009 +0000 +++ b/FrmArmyTree.cs Tue Sep 15 19:41:41 2009 +0000 @@ -314,19 +314,21 @@ private void EditUnit() { TreeNode selected = treeView.SelectedNode; + object tagData = selected.Tag; - if (selected.Tag!=null && selected.Tag is Unit) + if (tagData is Unit) { - Unit unit = (Unit)selected.Tag; + Unit unit = (Unit) tagData; + string unitID = unit.ID; - if (unitWindows.ContainsKey(unit.ID)) + if (unitWindows.ContainsKey(unitID)) { - unitWindows[unit.ID].Focus(); + unitWindows[unitID].Focus(); } else { FrmUnit unitForm = new FrmUnit(unit, commandStack); - unitWindows.Add(unit.ID, unitForm); + unitWindows.Add(unitID, unitForm); unitForm.MdiParent = this.MdiParent; unitForm.Closing+=new CancelEventHandler(unitForm_Closing); unitForm.Show();