Skip to content

Commit

Permalink
fix [on_undo] in menu items and custom_command
Browse files Browse the repository at this point in the history
also fixes menu items beeing marked as undoabel even if they used the
synced rng.
  • Loading branch information
gfgtdf committed Apr 30, 2018
1 parent fd370f5 commit 55065e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/actions/undo.cpp
Expand Up @@ -107,6 +107,8 @@ undo_action_base * undo_list::create_action(const config & cfg)

else if ( str == "update_shroud" )
res = new undo::update_shroud_action();
else if ( str == "dummy" )
res = new undo_dummy_action(cfg);
else
{
// Unrecognized type.
Expand Down
1 change: 1 addition & 0 deletions src/actions/undo_action.hpp
Expand Up @@ -101,6 +101,7 @@ namespace actions {
/// Undoes this action.
virtual bool undo(int)
{
execute_undo_umc_wml();
return true;
}
};
Expand Down
11 changes: 9 additions & 2 deletions src/synced_commands.cpp
Expand Up @@ -336,7 +336,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(fire_event, child, use_undo, /*show*/, /*error_

// Not clearing the undo stack here causes OOS because we added an entry to the replay but no entry to the undo stack.
if(use_undo) {
if(!undoable) {
if(!undoable || !synced_context::can_undo()) {
resources::undo_stack->clear();
} else {
resources::undo_stack->add_dummy();
Expand All @@ -345,10 +345,17 @@ SYNCED_COMMAND_HANDLER_FUNCTION(fire_event, child, use_undo, /*show*/, /*error_
return true;
}

SYNCED_COMMAND_HANDLER_FUNCTION(custom_command, child, /*use_undo*/, /*show*/, /*error_handler*/)
SYNCED_COMMAND_HANDLER_FUNCTION(custom_command, child, use_undo, /*show*/, /*error_handler*/)
{
assert(resources::lua_kernel);
resources::lua_kernel->custom_command(child["name"], child.child_or_empty("data"));
if(use_undo) {
if(!synced_context::can_undo()) {
resources::undo_stack->clear();
} else {
resources::undo_stack->add_dummy();
}
}
return true;
}

Expand Down

0 comments on commit 55065e1

Please sign in to comment.