13
0

Merge branch 'ardour'

This commit is contained in:
Robin Gareus 2024-08-13 03:11:15 +02:00
commit 5bcf0a5910
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -4937,11 +4937,10 @@ Editor::remove_clicked_region ()
playlist->remove_region (region); playlist->remove_region (region);
if (should_ripple()) { if (should_ripple()) {
do_ripple (playlist, region->position(), - region->length(), std::shared_ptr<Region>(), true); do_ripple (playlist, region->position(), - region->length(), std::shared_ptr<Region>(), false);
} else {
playlist->rdiff_and_add_command (_session);
} }
playlist->rdiff_and_add_command (_session);
commit_reversible_command (); commit_reversible_command ();
} }
@ -5009,6 +5008,13 @@ Editor::remove_regions (const RegionSelection& sel, bool can_ripple, bool as_par
vector<std::shared_ptr<Playlist> > playlists; vector<std::shared_ptr<Playlist> > 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<std::shared_ptr<Region> >::iterator rl = regions_to_remove.begin(); rl != regions_to_remove.end(); ++rl) { for (list<std::shared_ptr<Region> >::iterator rl = regions_to_remove.begin(); rl != regions_to_remove.end(); ++rl) {
std::shared_ptr<Playlist> playlist = (*rl)->playlist(); std::shared_ptr<Playlist> playlist = (*rl)->playlist();
@ -5018,16 +5024,14 @@ Editor::remove_regions (const RegionSelection& sel, bool can_ripple, bool as_par
continue; continue;
} }
/* get_regions_from_selection_and_entered() guarantees that if (std::find (playlists.begin(), playlists.end(), playlist) == playlists.end()) {
the playlists involved are unique, so there is no need playlists.push_back (playlist);
to check here.
*/
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); playlist->remove_region (*rl);
if (can_ripple && should_ripple()) { if (can_ripple && should_ripple()) {
@ -5036,27 +5040,24 @@ Editor::remove_regions (const RegionSelection& sel, bool can_ripple, bool as_par
} }
vector<std::shared_ptr<Playlist> >::iterator pl; vector<std::shared_ptr<Playlist> >::iterator pl;
bool in_command = false;
bool commit_result = false;
for (pl = playlists.begin(); pl != playlists.end(); ++pl) { for (pl = playlists.begin(); pl != playlists.end(); ++pl) {
commit_result = true;
(*pl)->thaw (); (*pl)->thaw ();
/* We might have removed regions, which alters other regions' layering_index, /* We might have removed regions, which alters other regions' layering_index,
so we need to do a recursive diff here. 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<Command*> cmds; vector<Command*> cmds;
(*pl)->rdiff (cmds); (*pl)->rdiff (cmds);
_session->add_commands (cmds); _session->add_commands (cmds);
_session->add_command(new StatefulDiffCommand (*pl)); _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 (); commit_reversible_command ();
} }
} }