mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-02 14:12:36 +00:00
gui2/tunit_create: Prevent null pointer dereferences
One code path in particular assumed that resources::controller is never a null pointer, thus breaking unit tests.
This commit is contained in:
parent
9fd59b503f
commit
49e3d20e7b
@ -288,9 +288,13 @@ void tunit_create::list_item_clicked(twindow& window)
|
||||
std::stringstream str;
|
||||
print_stats(str, selected_row);
|
||||
|
||||
const std::string& tc = "~RC("
|
||||
+ u->flag_rgb() + ">"
|
||||
+ team::get_side_color_index(resources::controller->play_controller::current_side()) + ")";
|
||||
std::string tc;
|
||||
|
||||
if(resources::controller) {
|
||||
tc = "~RC(" + u->flag_rgb() + ">" +
|
||||
team::get_side_color_index(resources::controller->play_controller::current_side())
|
||||
+ ")";
|
||||
}
|
||||
|
||||
const std::string& alignment_name = unit_type::alignment_description(
|
||||
u->alignment(),
|
||||
@ -326,6 +330,10 @@ void tunit_create::list_item_clicked(twindow& window)
|
||||
|
||||
void tunit_create::profile_button_callback(twindow& window)
|
||||
{
|
||||
if(!disp_) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int selected_row
|
||||
= find_widget<tlistbox>(&window, "unit_type_list", false).get_selected_row();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user