correctly abort the undo record when Editor::clear_markers (et al) have no effect

* move abort_reversible_command into the correct bracketed location

* check for missing _session at top of function to avoid unnecessary nesting

* this fixes an undo 'assert' when an action like "clear xrun markers" has no effect

* this was likely a copy+paste thinko since they are adjacent in the code
This commit is contained in:
Ben Loftis 2022-05-03 09:20:43 -05:00
parent dbd80a6dd0
commit 256549e0c7
1 changed files with 30 additions and 24 deletions

View File

@ -2509,7 +2509,10 @@ Editor::set_mark ()
void
Editor::clear_markers ()
{
if (_session) {
if (!_session) {
return;
}
begin_reversible_command (_("clear markers"));
XMLNode &before = _session->locations()->get_state();
@ -2517,7 +2520,6 @@ Editor::clear_markers ()
XMLNode &after = _session->locations()->get_state();
_session->add_command(new MementoCommand<Locations>(*(_session->locations()), &before, &after));
commit_reversible_command ();
}
} else {
abort_reversible_command ();
}
@ -2526,7 +2528,10 @@ Editor::clear_markers ()
void
Editor::clear_xrun_markers ()
{
if (_session) {
if (!_session) {
return;
}
begin_reversible_command (_("clear xrun markers"));
XMLNode &before = _session->locations()->get_state();
@ -2535,7 +2540,6 @@ Editor::clear_xrun_markers ()
_session->add_command(new MementoCommand<Locations>(*(_session->locations()), &before, &after));
commit_reversible_command ();
}
} else {
abort_reversible_command ();
}
@ -2544,7 +2548,10 @@ Editor::clear_xrun_markers ()
void
Editor::clear_ranges ()
{
if (_session) {
if (!_session) {
return;
}
begin_reversible_command (_("clear ranges"));
XMLNode &before = _session->locations()->get_state();
@ -2555,7 +2562,6 @@ Editor::clear_ranges ()
_session->add_command(new MementoCommand<Locations>(*(_session->locations()), &before, &after));
commit_reversible_command ();
}
} else {
abort_reversible_command ();
}