From dfd44c2ebf9b3fb4d2f84146bd79e94325c5520d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 2 Oct 2023 03:13:31 +0200 Subject: [PATCH] Fix 3-point edit undo/redo #9464 Playlist::split can result in removal of a region (adding two others instead). In this case the state of the removed region (if modified) is not saved. --- libs/ardour/session.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index e0465bc927..eb0282aea3 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -7279,6 +7279,15 @@ Session::cut_copy_section (timepos_t const& start_, timepos_t const& end_, timep } if (op != DeleteSection) { + /* Commit changes so far, to retain undo sequence. + * split() may create a new region replacing the already + * rippled of regions, the length/position of which + * would not be saved/restored. + */ + pl->rdiff_and_add_command (this); + pl->clear_changes (); + pl->clear_owned_changes (); + /* now make space at the insertion-point */ pl->split (to); pl->ripple (to, start.distance(end), NULL); @@ -7288,13 +7297,10 @@ Session::cut_copy_section (timepos_t const& start_, timepos_t const& end_, timep pl->paste (p, to, 1); } - vector cmds; - pl->rdiff (cmds); - add_commands (cmds); - add_command (new StatefulDiffCommand (pl)); + pl->rdiff_and_add_command (this); } - for (auto& pl : _playlists->playlists) { + for (auto& pl : playlists) { pl->thaw (); }