Fixed a crash with ImTui on a fresh CDDA install #72235
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "On a fresh install, ImTui crashes and burns on loading"
Purpose of change
cataimgui::client::client() calls color_loader::load which doesn't ensure that the config directory exists before trying to populate it with the color JSON. This was OK before because base_colors.json wasn't needed on ncurses builds, now we need it for ImTui though.
Describe the solution
call ensure_dir_exist() inside color_loader::load to make sure the config directory exists.
Describe alternatives you've considered
the crash in ImTui/ImGui is supposed to be caught by the debug dialog, but ui_manager::redraw_invalidated() calls into cataimgui::client::new_frame(), which blows up when the client has not been initialized. in other words, right now CDDA will just crash when a debug error is thrown during loading, which is a significant regression which we must deal with eventually.
Testing
deleted my config directory and loaded the game and observed the lack of a crash.
Additional context