gui2/unit_create: Fix segfault on empty list when updating unit preview

This happens when the list comes up empty because of a non-matching
filter, e.g. "Elvish Archer222" and the user clicks on one of the gender
options in this state.

Ideally we should clear the preview pane and disable the options and OK
button here, but the former appears impossible and for some reason
changing the pane's visibility in filter_text_changed() doesn't work
reliably.

(cherry-picked from commit 26629d4a62)
This commit is contained in:
Iris Morelle 2018-09-01 18:36:40 -03:00
parent 2b6b1ed4fe
commit 7fe7047ba9
2 changed files with 7 additions and 0 deletions

View file

@ -62,6 +62,9 @@
* Fix some minor problems in macOS package
* Fast Micro AI: Fix bug crashing the AI when units with chance-to-hit
specials without id are on map
* Fixed the debug mode Create Unit dialog crashing when changing the gender
of the previous selection after causing the list to come up empty using
the filter box.
## Version 1.14.4
### Security Fixes

View file

@ -181,6 +181,10 @@ void unit_create::update_displayed_type() const
const int selected_row
= find_widget<listbox>(w, "unit_type_list", false).get_selected_row();
if(selected_row == -1) {
return;
}
find_widget<unit_preview_pane>(w, "unit_details", false)
.set_displayed_type(units_[selected_row]->get_gender_unit_type(gender_));
}