diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index d75562c7f79..7478cbfdb97 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -932,8 +932,23 @@ void CanvasItemEditor::_restore_canvas_item_state(List p_canvas_it } void CanvasItemEditor::_commit_canvas_item_state(List p_canvas_items, String action_name, bool commit_bones) { - undo_redo->create_action(action_name); + List modified_canvas_items; for (List::Element *E = p_canvas_items.front(); E; E = E->next()) { + CanvasItem *canvas_item = E->get(); + Dictionary old_state = editor_selection->get_node_editor_data(canvas_item)->undo_state; + Dictionary new_state = canvas_item->_edit_get_state(); + + if (old_state.hash() != new_state.hash()) { + modified_canvas_items.push_back(canvas_item); + } + } + + if (modified_canvas_items.empty()) { + return; + } + + undo_redo->create_action(action_name); + for (List::Element *E = modified_canvas_items.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data(canvas_item); undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state());