# HG changeset patch # User IBBoard # Date 1246133601 0 # Node ID 85db2c9a154673f76d996e60867ae895d1e15509 # Parent abbf8a3ac43167f83728f169db639cbf03a9e83d Fixes #95: Can't re-open GTK# tabs * Make Unit for UnitDisplayWidget visible as a property * Hook in to Destroyed event of UnitDisplayWidget to remove it from the map of tabs diff -r abbf8a3ac431 -r 85db2c9a1546 FrmMainWindow.cs --- a/FrmMainWindow.cs Sat Jun 27 19:39:41 2009 +0000 +++ b/FrmMainWindow.cs Sat Jun 27 20:13:21 2009 +0000 @@ -130,7 +130,6 @@ PointsValueChangedMethod = new DoubleValChangedDelegate(OnPointsValueChanged); FailedUnitRequirementMethod = new FailedUnitRequirementDelegate(OnFailedUnitRequirement); UnitNameChangedMethod = new StringValChangedDelegate(OnUnitNameChanged); - logger.Debug("Initialising complete - trying to load default army or system"); //FIXME: Temporary hack to add paths and factories WarFoundryLoader.GetDefault().AddLoadDirectory(new DirectoryInfo(Constants.ExecutablePath + Constants.DirectoryString + "data")); @@ -147,6 +146,8 @@ { WarFoundryLoader.GetDefault().RegisterNonNativeFactory((INonNativeWarFoundryFactory)factory); } + + logger.Debug("Initialising complete - seeing if we can load default army or system"); if (args.Length == 1) { @@ -918,6 +919,7 @@ widget = new UnitDisplayWidget(unit, CommandStack); logger.Debug("Adding page for "+unit.Name); unitToWidgetMap[unit] = widget; + widget.Destroyed+= new EventHandler(UnitWidgetDestroyed); int pageNum = NotebookUtil.AddPageToNotebookWithCloseButton(unitsNotebook, widget, unit.Name); logger.Debug("Page added at index "+pageNum); unitsNotebook.ShowAll(); @@ -925,5 +927,13 @@ } } } + + private void UnitWidgetDestroyed(object sender, EventArgs e) + { + if (sender is UnitDisplayWidget) + { + unitToWidgetMap.Remove(((UnitDisplayWidget)sender).Unit); + } + } } } diff -r abbf8a3ac431 -r 85db2c9a1546 Widgets/UnitDisplayWidget.cs --- a/Widgets/UnitDisplayWidget.cs Sat Jun 27 19:39:41 2009 +0000 +++ b/Widgets/UnitDisplayWidget.cs Sat Jun 27 20:13:21 2009 +0000 @@ -82,6 +82,11 @@ (cell as CellRendererText).Text = u.GetStatValue(column.Title); } } + + public IBBoard.WarFoundry.API.Objects.Unit Unit + { + get { return unit; } + } private void UnitNameChanged(WarFoundryObject obj, string oldValue, string newValue) {