fix assertion failure when dismissing units

http://gna.org/bugs/?23510
This commit is contained in:
gfgtdf 2015-04-23 22:13:57 +02:00
parent ba3f4129fe
commit a8da5e2b6d
2 changed files with 7 additions and 2 deletions

View file

@ -150,8 +150,6 @@ gui::dialog_button_action::RESULT delete_recall_unit::button_pressed(int menu_se
// Remove the item from filter_textbox memory
filter_.delete_item(menu_selection);
//add dismissal to the undo stack
resources::undo_stack->add_dismissal(u_ptr);
LOG_DP << "Dismissing a unit, side = " << u.side() << " id = '" << u.id() << "'\n";
LOG_DP << "That side's recall list:\n";

View file

@ -232,6 +232,13 @@ SYNCED_COMMAND_HANDLER_FUNCTION(disband, child, /*use_undo*/, /*show*/, error_ha
const std::string& unit_id = child["value"];
size_t old_size = current_team.recall_list().size();
// Find the unit in the recall list.
unit_ptr dismissed_unit = current_team.recall_list().find_if_matches_id(unit_id);
assert(dismissed_unit);
//add dismissal to the undo stack
resources::undo_stack->add_dismissal(dismissed_unit);
current_team.recall_list().erase_if_matches_id(unit_id);
if (old_size == current_team.recall_list().size()) {