Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#287 closed defect (released)

New DataGridView crashes FrmUnit under Mono

Reported by: ibboard Owned by: ibboard
Priority: critical Milestone: WarFoundry 0.1
Component: WarFoundry-GUI-WinForms Version: Trunk
Keywords: datagridview stats mono Cc:
Blocked By: Blocking:


If WarFoundry is used under Mono then the DataGridView behaves slightly differently to under Windows. Instead of showing the stats, the grid view causes a crash because of an index out of bounds:

DEBUG [20:05:08]: FrmUnit.SetStats() - Line: 0 - Unit Empire General has 1 stats arrays
DEBUG [20:05:08]: FrmUnit.CreateDataGridView() - Line: 0 - Create DataGridView for stats ID whDefault
DEBUG [20:05:08]: FrmUnit.CreateDataGridView() - Line: 0 - Create DataGridView widget
DEBUG [20:05:08]: FrmUnit.CreateDataColumn() - Line: 0 - Create column Name
System.ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count.
Parameter name: index
  at System.Collections.ArrayList.ThrowNewArgumentOutOfRangeException (System.String name, System.Object actual, System.String message) [0x00000] in <filename unknown>:0 
  at System.Collections.ArrayList.get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.DataGridViewColumnCollection.get_Item (Int32 index) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.DataGridViewColumnCollection:get_Item (int)
  at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.CreateDataGridView (System.String statsID) [0x00000] in <filename unknown>:0 
  at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.GetDataGridView (System.String statsID) [0x00000] in <filename unknown>:0 
  at IBBoard.WarFoundry.GUI.WinForms.FrmUnit.SetStats () [0x00000] in <filename unknown>:0 
  at IBBoard.WarFoundry.GUI.WinForms.FrmUnit..ctor (IBBoard.WarFoundry.API.Objects.Unit toDisplay, IBBoard.Commands.CommandStack cmdStack) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) IBBoard.WarFoundry.GUI.WinForms.FrmUnit:.ctor (IBBoard.WarFoundry.API.Objects.Unit,IBBoard.Commands.CommandStack)
  at IBBoard.WarFoundry.GUI.WinForms.FrmMain.OpenUnitDialog (IBBoard.WarFoundry.API.Objects.Unit unit) [0x00000] in <filename unknown>:0 
  at IBBoard.WarFoundry.GUI.WinForms.FrmMain.AddUnitFromCategory (IBBoard.WarFoundry.API.Objects.Category cat) [0x00000] in <filename unknown>:0 
  at IBBoard.WarFoundry.GUI.WinForms.FrmMain.CreateUnitForCategoryButtonClick (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripItem.OnClick (System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripButton.OnClick (System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripItem.HandleClick (System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStripItem.FireEvent (System.EventArgs e, ToolStripItemEventType met) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.ToolStripItem:FireEvent (System.EventArgs,System.Windows.Forms.ToolStripItemEventType)
  at System.Windows.Forms.ToolStrip.OnMouseUp (System.Windows.Forms.MouseEventArgs mea) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control.WmLButtonUp (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ToolStrip.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr wParam, IntPtr lParam) [0x00000] in <filename unknown>:0 

From the code, it looks like we assume that a column exists in the view because it has been created in the data table, but Mono doesn't behave in quite the same way.

Change History (3)

comment:1 Changed 10 years ago by ibboard

Owner: set to ibboard
Status: newaccepted

comment:2 Changed 10 years ago by ibboard

Resolution: fixed
Status: acceptedclosed

(In r576) Fixes #287: New DataGridView crashes FrmUnit under Mono

  • Make sure that columns are explicitly defined and not implicitly created
  • Add proper stat line name column translation

comment:3 Changed 10 years ago by ibboard

Resolution: fixedreleased

Release as part of v0.1b9

Note: See TracTickets for help on using tickets.