From 9f0b829cfb474c4aff1e9fee979a5fa5f58e5734 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 13 Aug 2024 03:05:19 +0200 Subject: [PATCH 1/2] Fix undo when ripple deleting a region (#9767) --- gtk2_ardour/editor_ops.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 9619a914cb..6bde828220 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4931,11 +4931,10 @@ Editor::remove_clicked_region () playlist->remove_region (region); if (should_ripple()) { - do_ripple (playlist, region->position(), - region->length(), std::shared_ptr(), true); - } else { - playlist->rdiff_and_add_command (_session); + do_ripple (playlist, region->position(), - region->length(), std::shared_ptr(), false); } + playlist->rdiff_and_add_command (_session); commit_reversible_command (); } From b501eaf43ad8f92044b4eaf35f18f3aa7cdc8de4 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 13 Aug 2024 03:07:24 +0200 Subject: [PATCH 2/2] Fix undo when removing multiple regions on the same track --- gtk2_ardour/editor_ops.cc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 6bde828220..cdd7aee464 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -5002,6 +5002,13 @@ Editor::remove_regions (const RegionSelection& sel, bool can_ripple, bool as_par vector > playlists; + if (!as_part_of_other_command) { + /* we need to start the undo coammd here, since + * other playlists maybe modified as result of a ripple + */ + begin_reversible_command (_("remove regions")); + } + for (list >::iterator rl = regions_to_remove.begin(); rl != regions_to_remove.end(); ++rl) { std::shared_ptr playlist = (*rl)->playlist(); @@ -5011,16 +5018,14 @@ Editor::remove_regions (const RegionSelection& sel, bool can_ripple, bool as_par continue; } - /* get_regions_from_selection_and_entered() guarantees that - the playlists involved are unique, so there is no need - to check here. - */ + if (std::find (playlists.begin(), playlists.end(), playlist) == playlists.end()) { + playlists.push_back (playlist); - playlists.push_back (playlist); + playlist->clear_changes (); + playlist->clear_owned_changes (); + playlist->freeze (); + } - playlist->clear_changes (); - playlist->clear_owned_changes (); - playlist->freeze (); playlist->remove_region (*rl); if (can_ripple && should_ripple()) { @@ -5029,27 +5034,24 @@ Editor::remove_regions (const RegionSelection& sel, bool can_ripple, bool as_par } vector >::iterator pl; - bool in_command = false; + + bool commit_result = false; for (pl = playlists.begin(); pl != playlists.end(); ++pl) { + commit_result = true; (*pl)->thaw (); /* We might have removed regions, which alters other regions' layering_index, so we need to do a recursive diff here. */ - if (!in_command && !as_part_of_other_command) { - begin_reversible_command (_("remove region")); - in_command = true; - } vector cmds; (*pl)->rdiff (cmds); _session->add_commands (cmds); - _session->add_command(new StatefulDiffCommand (*pl)); } - if (in_command && !as_part_of_other_command) { + if (commit_result && !as_part_of_other_command) { commit_reversible_command (); } }