diff --git a/modules/paint/actions/paint_action.cpp b/modules/paint/actions/paint_action.cpp index ec91b19d6..f55f231ff 100644 --- a/modules/paint/actions/paint_action.cpp +++ b/modules/paint/actions/paint_action.cpp @@ -181,6 +181,25 @@ void PaintAction::draw_points(PaintCanvas *canvas, const PoolVector2iArray &poin } } +void PaintAction::copy_data_from(const Ref &other) { + action_data_undo = other->action_data_undo.duplicate(true); + action_data_redo = other->action_data_redo.duplicate(true); + action_data_preview = other->action_data_preview.duplicate(true); + + undo_cells.append_array(other->undo_cells); + undo_colors.append_array(other->undo_colors); + + redo_cells.append_array(other->redo_cells); + redo_colors.append_array(other->redo_colors); + + preview_cells.append_array(other->preview_cells); + preview_colors.append_array(other->preview_colors); + + layer = other->layer; + + action_data = other->action_data.duplicate(true); +} + PaintAction::PaintAction() { } diff --git a/modules/paint/actions/paint_action.h b/modules/paint/actions/paint_action.h index 42c5457b9..18189895c 100644 --- a/modules/paint/actions/paint_action.h +++ b/modules/paint/actions/paint_action.h @@ -56,6 +56,8 @@ public: void draw_points(PaintCanvas *canvas, const PoolVector2iArray &point_arr, const PoolColorArray &color_arr); + void copy_data_from(const Ref &other); + PaintAction(); ~PaintAction(); diff --git a/modules/paint/paint_window.cpp b/modules/paint/paint_window.cpp index b7300340f..eed601f69 100644 --- a/modules/paint/paint_window.cpp +++ b/modules/paint/paint_window.cpp @@ -609,7 +609,8 @@ void PaintWindow::commit_action() { //print("commit action") _current_action->commit_action(paint_canvas); Ref action = get_action(); - action->action_data = _current_action->action_data.duplicate(true); + action->copy_data_from(_current_action); + _actions_history.push_back(action); _redo_history.clear();