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 at startup on Windows #2557

Merged
merged 1 commit into from
Oct 28, 2018

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Oct 27, 2018

Problem

If you run the master HEAD version in Windows, you get this exception at startup:

Unhandled exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentNullException: Value cannot be null.
Parameter name: container
   at System.Windows.Forms.ContextMenuStrip..ctor(IContainer container)
   at CKAN.SettingsDialog.InitializeComponent()
   at CKAN.SettingsDialog..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance[T]()
   at CKAN.ControlFactory.CreateControl[T]()
   at CKAN.Main.RecreateDialogs()
   at CKAN.Main..ctor(String[] cmdlineArgs, KSPManager mgr, GUIUser user, Boolean showConsole)
   at CKAN.GUI.Main_(String[] args, KSPManager manager, Boolean showConsole)
   at CKAN.CmdLine.MainClass.Gui(KSPManager manager, GuiOptions options, String[] args)
   at CKAN.CmdLine.MainClass.RunSimpleAction(Options cmdline, CommonOptions options, String[] args, IUser user, KSPManager manager)
   at CKAN.CmdLine.MainClass.Execute(KSPManager manager, CommonOptions opts, String[] args)
   at CKAN.CmdLine.MainClass.Main(String[] args) 

Cause

This line initializes the purge button dropdown menu from #2536 in the settings window:

this.ClearCacheMenu = new System.Windows.Forms.ContextMenuStrip(this.components);

However, this.components isn't currently being set. In the main form from which the above line was borrowed, there's a line to set it, but this isn't present in the settings form:

this.components = new System.ComponentModel.Container();

We should have copied and pasted this when we made the dropdown, but it's not apparent that it's required or might be missing.

Changes

Now this.components is initialized in the settings window and the exception is gone.

The cache settings text boxes are also made 5 pixels taller, since they were a bit squished on Windows previously.

@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI Pull request Windows Issues specific for Windows labels Oct 27, 2018
@HebaruSan HebaruSan force-pushed the fix/windows-settings-exception branch from c00dc02 to 47155a0 Compare October 27, 2018 22:38
@Olympic1 Olympic1 merged commit 47155a0 into KSP-CKAN:master Oct 28, 2018
Olympic1 added a commit that referenced this pull request Oct 28, 2018
@HebaruSan HebaruSan deleted the fix/windows-settings-exception branch October 28, 2018 19:38
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