#295 closed defect (released)
Index out of bounds when changing unit size and clicking in equipment list
Reported by: | Henri | Owned by: | ibboard |
---|---|---|---|
Priority: | critical | Milestone: | WarFoundry 0.1 |
Component: | WarFoundry-GUI-WinForms | Version: | WarFoundry 0.1b9 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
As discussed here:
http://forums.hiveworldterra.co.uk/viewtopic.php?f=40&t=1427&start=30
there seems to be issues
If there is an item min/max size tag with a min of "0", that means it is no longer defaulted. A min size of "1" will have it selected. However, in this case increasing the unit size will cause an exception with the following text. If you ignore the error and just add another item or option with it works.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
Exception Text
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Windows.Forms.ListBox.ItemArray.GetItem(Int32 virtualIndex, Int32 stateMask)
at System.Windows.Forms.ListBox.SelectedObjectCollection.get_Item(Int32 index)
at System.Windows.Forms.ListBox.get_SelectedItem()
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.GetSelectedUnitEquipmentChoice()
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.GetSelectedUnitEquipmentItem()
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.SetButtonsEnabledState()
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.equipmentList_SelectedIndexChanged(Object sender, EventArgs e)
at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ListBox.ObjectCollection.SetItemInternal(Int32 index, Object value)
at System.Windows.Forms.ListBox.ObjectCollection.set_Item(Int32 index, Object value)
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.SetEquipmentListValue(UnitEquipmentChoice equipChoice)
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.RefreshUnitEquipment()
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.unit_UnitSizeChanged(WarFoundryObject obj, Int32 oldValue, Int32 newValue)
at IBBoard.WarFoundry.API.IntValChangedDelegate.Invoke(WarFoundryObject obj, Int32 oldValue, Int32 newValue)
at IBBoard.WarFoundry.API.Objects.Unit.OnUnitSizeChanged(Int32 oldValue, Int32 newValue) in Y:\IBBoard.WarFoundry.API\api\Objects\Unit.cs:line 463
at IBBoard.WarFoundry.API.Objects.Unit.set_Size(Int32 value) in Y:\IBBoard.WarFoundry.API\api\Objects\Unit.cs:line 136
at IBBoard.WarFoundry.API.Commands.SetUnitSizeCommand.Redo() in Y:\IBBoard.WarFoundry.API\api\Commands\SetUnitSizeCommand.cs:line 68
at IBBoard.WarFoundry.API.Commands.SetUnitSizeCommand.Execute() in Y:\IBBoard.WarFoundry.API\api\Commands\SetUnitSizeCommand.cs:line 62
at IBBoard.Commands.CommandStack.Execute(Command cmd)
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.UpdateUnitSize()
at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.unitSize_Leave(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnLeave(EventArgs e)
at System.Windows.Forms.Control.NotifyLeave()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()
Loaded Assemblies
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4200 (NetFxQFE.050727-4200)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
Assembly Version: 0.0.1.35596
Win32 Version: 0.0.1.35596
CodeBase: file:///C:/Users/Henri/Desktop/WarFoundry-WinForms-v0.1-beta-9/WarFoundry.exe
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4205 (VistaSP2GDR.050727-4200)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
log4net
Assembly Version: 1.2.10.0
Win32 Version: 1.2.10.0
CodeBase: file:///C:/Users/Henri/Desktop/WarFoundry-WinForms-v0.1-beta-9/log4net.DLL
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
IBBoard
Assembly Version: 1.0.3803.35595
Win32 Version: 1.0.3803.35595
CodeBase: file:///C:/Users/Henri/Desktop/WarFoundry-WinForms-v0.1-beta-9/IBBoard.DLL
IBBoardWF
Assembly Version: 1.0.0.35596
Win32 Version: 1.0.0.35596
CodeBase: file:///C:/Users/Henri/Desktop/WarFoundry-WinForms-v0.1-beta-9/IBBoardWF.DLL
IBBoard.WarFoundry.API
Assembly Version: 0.0.1.35596
Win32 Version: 0.0.1.35596
CodeBase: file:///C:/Users/Henri/Desktop/WarFoundry-WinForms-v0.1-beta-9/IBBoard.WarFoundry.API.DLL
ICSharpCode.SharpZipLib
Assembly Version: 0.85.5.452
Win32 Version: 0.85.5.452
CodeBase: file:///C:/Users/Henri/Desktop/WarFoundry-WinForms-v0.1-beta-9/ICSharpCode.SharpZipLib.DLL
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.4016 (NetFxQFE.050727-4000)
CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
Attachments (1)
Change History (12)
comment:1 Changed 10 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 10 years ago by
Owner: | set to Henri |
---|---|
Status: | confirmed → needinfo |
I've tried several different ways of recreating your bug and I can't at the moment. Can you provide the data file and exact instructions on what to do to recreate the problem (what you clicked on and in what order)?
comment:3 Changed 9 years ago by
Essentially, if you pick an Attack bike form the Fast Attack category. It will come with 1 as default. If you add 1 heavy bolter, then increase the unit size to 2. It may throw the exception. I'm having trouble pinning it down, but it seems that when I change the unit size and the cursor (or selected line, it's blue marked in Windows) is on the heavy bolter option. This seems to "work":
Make sure the cursor was last on the heavy bolter item. Change the units size and click on another equipment choice, or the same heavy bolter in some cases it seems. IE click in the equipment window. And "hopefully" it will throw the exception.
If you click somewhere else to let it "recalculate" it will not crash.
I would like to see a split between "required" and "default" I think. Required should be non-swappable equipment only. Default would be items you are initially armed with but may not be so when you have upgraded.
comment:4 Changed 9 years ago by
Owner: | changed from Henri to ibboard |
---|---|
Status: | needinfo → accepted |
I'll check this out next time I'm on my desktop, but I'm suspecting it might be a race condition. The methods in the stack trace are for re-filling the list with the updated strings. Depending on how I do it then I guess there could be problems if the last item is selected, as it might remove the item and so the selection won't be valid.
As for required vs default - put in a ticket for it, but at the moment the idea is that the first required item for each equipment slot is added and that future code will ensure that you can never remove the items, even if not all of the alternatives are tagged "required". Required/default might be neater, though.
comment:5 Changed 9 years ago by
Ah, finally found how to recreate it. The important part seems to be clicking into the equipment box after making the change rather than clicking anywhere else. I'm not sure why it makes a difference and why it would error when we're setting an existing value rather than removing and re-adding, but there you go.
Now to find the fix...
comment:6 Changed 9 years ago by
Component: | WarFoundry-API → WarFoundry-GUI-WinForms |
---|---|
Milestone: | → WarFoundry 0.1 |
Priority: | minor → critical |
Summary: | Required item interaction issues → Index out of bounds when changing unit size and clicking in equipment list |
comment:7 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
comment:8 Changed 9 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Re-open for a better solution
comment:9 Changed 9 years ago by
comment:10 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:11 Changed 9 years ago by
Resolution: | fixed → released |
---|
Retro-actively tag RC1 releases as released
I'm not sure what is best with the min size of 0. If it is required/default then you shouldn't be able to take 0 of it. What are the specific use cases for it and what do they need?