Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on marking all updates #3079

Merged
merged 1 commit into from
Jun 15, 2020

Conversation

HebaruSan
Copy link
Member

Problem

  1. Have some upgradeable mods (you can install old versions in the Versions tab for testing)
  2. Switch to the "Newly compatible filter" when it's empty (i.e., nothing is newly compatible)
  3. Click "Add available updates"
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.ArrayList.get_Item (System.Int32 index) [0x0000d] in <a5e6a8b38be74ec1b9abd482cb076c8a>:0 
  at System.Windows.Forms.DataGridViewRowCollection.get_Item (System.Int32 index) [0x00000] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at CKAN.ManageMods.MarkAllUpdates () [0x000fb] in <1e9e6cc7a1124c26a7e978a1dd44c3d6>:0 
  at CKAN.ManageMods.MarkAllUpdatesToolButton_Click (System.Object sender, System.EventArgs e) [0x00001] in <1e9e6cc7a1124c26a7e978a1dd44c3d6>:0 
  at System.Windows.Forms.ToolStripItem.OnClick (System.EventArgs e) [0x00019] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.ToolStripMenuItem.OnClick (System.EventArgs e) [0x00090] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.ToolStripMenuItem.HandleClick (System.Int32 mouse_clicks, System.EventArgs e) [0x00000] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.ToolStripItem.FireEvent (System.EventArgs e, System.Windows.Forms.ToolStripItemEventType met) [0x00054] in <5e01e3d59bfc48e1a1ea0509bb585d97>: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) [0x00048] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.Control.WmLButtonUp (System.Windows.Forms.Message& m) [0x00078] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m) [0x001b4] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.ScrollableControl.WndProc (System.Windows.Forms.Message& m) [0x00000] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.ToolStrip.WndProc (System.Windows.Forms.Message& m) [0x00000] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.MenuStrip.WndProc (System.Windows.Forms.Message& m) [0x00000] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage (System.Windows.Forms.Message& m) [0x00000] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc (System.Windows.Forms.Message& m) [0x0000b] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
  at System.Windows.Forms.NativeWindow.WndProc (System.IntPtr hWnd, System.Windows.Forms.Msg msg, System.IntPtr wParam, System.IntPtr lParam) [0x00085] in <5e01e3d59bfc48e1a1ea0509bb585d97>:0 
exception inside UnhandledException handler: (null) assembly:/media/DataTrove/mono-dev/lib/mono/4.5/mscorlib.dll type:InvalidOperationException member:(null)

Even if you have a few rows to avoid the crash, only updates with rows visible in the current filter will be marked.

Cause

ModGrid.Rows is empty when this line tries to access its first element:

// Select the top row and scroll the list to it.
ModGrid.CurrentCell = ModGrid.Rows[0].Cells[SelectableColumnIndex()];

And the updates are marked by looping over ModGrid.Rows, which only includes visible rows.

Changes

  • Now we check that ModGrid.Rows isn't empty before trying to access a row
  • Now we look for updates in mainModList.full_list_of_mod_rows.Values instead of just the visible rows

Fixes #3078.

@HebaruSan HebaruSan added Bug Something is not working as intended Easy This is easy to fix GUI Issues affecting the interactive GUI Pull request labels Jun 14, 2020
@HebaruSan HebaruSan requested a review from DasSkelett June 14, 2020 16:00
Copy link
Member

@DasSkelett DasSkelett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, works fine (and even reduces code size by one line!)

@HebaruSan HebaruSan merged commit e78b104 into KSP-CKAN:master Jun 15, 2020
@HebaruSan HebaruSan deleted the fix/mark-all-up branch June 15, 2020 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended Easy This is easy to fix GUI Issues affecting the interactive GUI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Crash when trying to "Add available updates" with empty mod list.
2 participants