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 selecting filtered-out provider module #2585

Merged
merged 1 commit into from
Nov 29, 2018

Conversation

HebaruSan
Copy link
Member

Problem

If you:

  1. Launch GUI
  2. Search/filter for a mod that has a virtual dependency, for example Realistic Progression Zero
  3. Check the box to install it
  4. Receive the prompt to select a mod to provide a dependency
  5. Select a mod that's not visible in the main mod list due to filtering

... then you'll get a crash:

screenshot

System.NullReferenceException: Object reference not set to an instance of an object.
   at CKAN.GUIMod.SetInstallChecked(DataGridViewRow row, Nullable`1 set_value_to)
   at CKAN.Main._MarkModForInstall(String identifier, Boolean uninstall)
   at CKAN.Main.<>c__DisplayClass264_0.<MarkModForInstall>b__0()
   at CKAN.Util.Invoke[T](T obj, Action action)
   at CKAN.Main.MarkModForInstall(String identifier, Boolean uncheck)
   at CKAN.Main.<TooManyModsProvide>d__237.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at CKAN.MainModList.<ComputeChangeSetFromModList>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at CKAN.Main.<UpdateChangeSetAndConflicts>d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at CKAN.Main.<ModList_CellValueChanged>d__274.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Cause

Apparently row.DataGridView is null here if the row isn't visible:

CKAN/GUI/GUIMod.cs

Lines 279 to 286 in c4f067b

if ((bool)install_cell.Value != IsInstallChecked)
{
install_cell.Value = IsInstallChecked;
// These calls are needed to force the UI to update,
// otherwise the checkbox will look checked when it's unchecked or vice versa
row.DataGridView.RefreshEdit();
row.DataGridView.Refresh();
}

WinForms loves surprises.

Changes

Now the crash no longer occurs.

We will just skip those calls if the reference is null. This should be fine as they were just added to force the checkbox to refresh in visible rows, and it's not necessary for invisible ones, as they seem to be re-initialized upon becoming visible.

Fixes #2584.

@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI Pull request Windows Issues specific for Windows labels Nov 23, 2018
@politas politas merged commit dfc7fb0 into KSP-CKAN:master Nov 29, 2018
@HebaruSan HebaruSan deleted the fix/filtered-provider-crash branch November 29, 2018 04:41
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 GUI Issues affecting the interactive GUI Windows Issues specific for Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants