diff options
author | kobewi <kobewi4e@gmail.com> | 2021-01-03 17:24:10 +0100 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2021-01-05 13:06:15 +0100 |
commit | 036f6a3fa8e35ba94c4f3f3e714d79ee2d10f2cc (patch) | |
tree | 1d149bba34e26d8fc982df333715cf43a08003ef /editor | |
parent | 950dedbb6858458b5944523bf806e35eb4d6a5d8 (diff) |
Commit CanvasItem state only if it changed
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 67b7a2af79..498f9d5c19 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -963,9 +963,24 @@ void CanvasItemEditor::_restore_canvas_item_state(List<CanvasItem *> p_canvas_it } void CanvasItemEditor::_commit_canvas_item_state(List<CanvasItem *> p_canvas_items, String action_name, bool commit_bones) { - undo_redo->create_action(action_name); + List<CanvasItem *> modified_canvas_items; for (List<CanvasItem *>::Element *E = p_canvas_items.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); + Dictionary old_state = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(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.is_empty()) { + return; + } + + undo_redo->create_action(action_name); + for (List<CanvasItem *>::Element *E = modified_canvas_items.front(); E; E = E->next()) { + CanvasItem *canvas_item = E->get(); CanvasItemEditorSelectedItem *se = editor_selection->get_node_editor_data<CanvasItemEditorSelectedItem>(canvas_item); undo_redo->add_do_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); |