kd8lvt / RimWorld-Math

A RimWorld mod
Other
4 stars 3 forks source link

Fix unhandled exceptions causing game-breaking issues #12

Closed Jacbo1 closed 2 weeks ago

Jacbo1 commented 2 weeks ago

The bill dialogs in my game were flickering, and interacting with certain UI components in certain bills would permanently break the entire bill dialog and its sub-dialogs rendering them unusable because there was no error handling. The errors in the log all pointed to this addon. One repeating error reported a null reference while another reported an unmatching amount of BeginScrollView and EndScrollView calls. The changes in this PR consist of many try-finally wrappings on begin-end patterns and a null check in the foreach loop inside RenderLinkSettings. node.Render(lt, 0); was throwing exceptions as sometimes node was null and then this would fall out of the RenderLinkSettings method entirely causing the Widgets.BeginScrollView(render_area, ref linkSettingsScrollPos, scroll_area); to never reach its closing Widgets.EndScrollView(); which caused this game-breaking behavior. This try-finally pattern was applied to all other ImGui begin-end patterns as a precaution to ensure that anywhere there is an exception, anything that was started with a begin will be ended.

The skill slider was also noninteractive because it had an ID of 0.

kd8lvt commented 2 weeks ago

Thanks for your work :) I've merged it here on GitHub, I'll release an update tomorrow or the day after to the Workshop. Feel free to poke me if I forget :)