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 reinstall prompt crash #3006

Merged
merged 1 commit into from
Feb 16, 2020
Merged

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Feb 16, 2020

Problem

My Mono does a hard crash when CKAN tries to ask the user whether to reinstall a changed mod after a refresh:

	  at <unknown> <0xffffffff>
	  at System.Windows.Forms.X11Keyboard:XCreateFontSet <0x000ce>
	  at System.Windows.Forms.X11Keyboard:CreateOverTheSpotXic <0x000e7>
	  at System.Windows.Forms.X11Keyboard:CreateXic <0x00117>
	  at System.Windows.Forms.X11Keyboard:CreateXicForWindow <0x00053>
	  at System.Windows.Forms.X11Keyboard:FocusIn <0x000c3>
	  at System.Windows.Forms.XplatUIX11:SetFocus <0x000ef>
	  at System.Windows.Forms.XplatUI:SetFocus <0x0003c>
	  at System.Windows.Forms.ContainerControl:SendControlFocus <0x000bf>
	  at System.Windows.Forms.Form:SetVisibleCore <0x004f3>
	  at System.Windows.Forms.Control:set_Visible <0x0004b>
	  at System.Windows.Forms.Control:set_Visible <0x00083>
	  at System.Windows.Forms.Application:RunLoop <0x003df>
	  at System.Windows.Forms.Form:ShowDialog <0x008f7>
	  at System.Windows.Forms.Form:ShowDialog <0x0002b>
	  at CKAN.YesNoDialog:ShowYesNoDialog <0x001cf>
	  at CKAN.YesNoDialog:ShowYesNoDialog <0x000a3>
	  at CKAN.Main:YesNoDialog <0x00057>
	  at CKAN.Main:YesNoDialog <0x000a3>
	  at CKAN.GUIUser:RaiseYesNoDialog <0x0003f>
	  at CKAN.Repo:HandleModuleChanges <0x001bf>
	  at CKAN.Repo:UpdateAllRepositories <0x00573>
	  at CKAN.Main:UpdateRepo <0x005c3>
	  at System.ComponentModel.BackgroundWorker:OnDoWork <0x00046>
	  at System.ComponentModel.BackgroundWorker:WorkerThreadStart <0x000c2>
	  at System.ComponentModel.BackgroundWorker:<RunWorkerAsync>b__27_0 <0x00033>
	  at System.Threading.Tasks.Task:InnerInvoke <0x0008f>
	  at System.Threading.Tasks.Task:Execute <0x00037>
	  at System.Threading.Tasks.Task:ExecutionContextCallback <0x0005b>
	  at System.Threading.ExecutionContext:RunInternal <0x00191>
	  at System.Threading.ExecutionContext:Run <0x00042>
	  at System.Threading.Tasks.Task:ExecuteWithThreadLocal <0x000f6>
	  at System.Threading.Tasks.Task:ExecuteEntry <0x000dc>
	  at System.Threading.Tasks.Task:System.Threading.IThreadPoolWorkItem.ExecuteWorkItem <0x00026>
	  at System.Threading.ThreadPoolWorkQueue:Dispatch <0x00279>
	  at System.Threading._ThreadPoolWaitCallback:PerformWaitCallback <0x0001c>
	  at <Module>:runtime_invoke_bool <0x00086>

Cause

The update runs on a background thread, and then it uses IUser to do GUI stuff.

Changes

Now YesNoDialog.ShowYesNoDialog does all its GUI operations on the GUI thread and uses a TaskCompetionSource to propagate the result back to the background thread.

I made the parent form a parameter because Util.Invoke wasn't reliably switching to the right thread in my testing when the first parameter was from the YesNo form. I think that parameter needs to be a UI object that's properly connected to the rest of the app. As a bonus, this means we can pass the parent form to ShowDialog.

I also realized that the if you had a ShowYesNoDialog call with the custom button caption parameters followed by a call without them, the buttons would keep the custom captions from the first call, so they need to be reset each time.

@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI Pull request labels Feb 16, 2020
@HebaruSan HebaruSan requested a review from DasSkelett February 16, 2020 01:23
HebaruSan added a commit that referenced this pull request Feb 16, 2020
@HebaruSan HebaruSan merged commit a3693f5 into KSP-CKAN:master Feb 16, 2020
@HebaruSan HebaruSan deleted the fix/gui-yesno branch April 3, 2020 18:18
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants