From 256549e0c73b9e79ccfd825480fb5c99209abaaf Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 3 May 2022 09:20:43 -0500 Subject: [PATCH] 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 --- gtk2_ardour/editor_ops.cc | 54 ++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 384421d280..bff50c8d2a 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -2509,15 +2509,17 @@ Editor::set_mark () void Editor::clear_markers () { - if (_session) { - begin_reversible_command (_("clear markers")); + if (!_session) { + return; + } - XMLNode &before = _session->locations()->get_state(); - if (_session->locations()->clear_markers ()) { - XMLNode &after = _session->locations()->get_state(); - _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); - commit_reversible_command (); - } + begin_reversible_command (_("clear markers")); + + XMLNode &before = _session->locations()->get_state(); + if (_session->locations()->clear_markers ()) { + XMLNode &after = _session->locations()->get_state(); + _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); + commit_reversible_command (); } else { abort_reversible_command (); } @@ -2526,16 +2528,18 @@ Editor::clear_markers () void Editor::clear_xrun_markers () { - if (_session) { - begin_reversible_command (_("clear xrun markers")); + if (!_session) { + return; + } - XMLNode &before = _session->locations()->get_state(); - if (_session->locations()->clear_xrun_markers ()) { - XMLNode &after = _session->locations()->get_state(); - _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); + begin_reversible_command (_("clear xrun markers")); - commit_reversible_command (); - } + XMLNode &before = _session->locations()->get_state(); + if (_session->locations()->clear_xrun_markers ()) { + XMLNode &after = _session->locations()->get_state(); + _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); + + commit_reversible_command (); } else { abort_reversible_command (); } @@ -2544,18 +2548,20 @@ Editor::clear_xrun_markers () void Editor::clear_ranges () { - if (_session) { - begin_reversible_command (_("clear ranges")); + if (!_session) { + return; + } - XMLNode &before = _session->locations()->get_state(); + begin_reversible_command (_("clear ranges")); - if (_session->locations()->clear_ranges ()) { + XMLNode &before = _session->locations()->get_state(); - XMLNode &after = _session->locations()->get_state(); - _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); + if (_session->locations()->clear_ranges ()) { - commit_reversible_command (); - } + XMLNode &after = _session->locations()->get_state(); + _session->add_command(new MementoCommand(*(_session->locations()), &before, &after)); + + commit_reversible_command (); } else { abort_reversible_command (); }