tweak block-labors: fix crash if unit is null

Fixes #1057
develop
lethosor 2018-05-11 10:21:05 -04:00
parent ceaa518be9
commit 9d353c1ea7
1 changed files with 3 additions and 2 deletions

@ -16,12 +16,13 @@ struct block_labors_hook : df::viewscreen_dwarfmodest {
inline bool valid_mode()
{
return ui->main.mode == df::ui_sidebar_mode::ViewUnits &&
ui_unit_view_mode->value == df::ui_unit_view_mode::T_value::PrefLabor;
ui_unit_view_mode->value == df::ui_unit_view_mode::T_value::PrefLabor &&
Gui::getAnyUnit(this);
}
inline bool forbidden_labor (df::unit *unit, df::unit_labor labor)
{
return is_valid_enum_item(labor) && !Units::isValidLabor(unit, labor);
return is_valid_enum_item(labor) && unit && !Units::isValidLabor(unit, labor);
}
inline bool all_labors_enabled (df::unit *unit, df::unit_labor_category cat)