Skip to content

Commit

Permalink
gui2/unit_create: Fix segfault on empty list when updating unit preview
Browse files Browse the repository at this point in the history
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 26629d4)
  • Loading branch information
irydacea committed Oct 7, 2018
1 parent 2b6b1ed commit 7fe7047
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/gui/dialogs/unit_create.cpp
Expand Up @@ -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_));
}
Expand Down

0 comments on commit 7fe7047

Please sign in to comment.