From 8794145c9d81f4e5d8e9e68165211b1223c6ce5f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 2 Jun 2023 18:07:02 +0200 Subject: [PATCH] Centralize setting undo/redo action sensitivity This fixes undo/redo action sensitivity for non-editor history stack changes. Notably recording was not undoable, because the butler thread creates the reversible "capture" command. --- gtk2_ardour/editor.cc | 12 ++++++++---- gtk2_ardour/editor_ops.cc | 10 +--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 4302cd1270..16b53d483e 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -3796,8 +3796,6 @@ Editor::commit_reversible_command () if (_session) { if (before.size() == 1) { _session->add_command (new MementoCommand(*(_selection_memento), before.front(), &_selection_memento->get_state ())); - redo_action->set_sensitive(false); - undo_action->set_sensitive(true); begin_selection_op_history (); } @@ -3815,18 +3813,24 @@ Editor::commit_reversible_command () void Editor::history_changed () { + if (!_session) { + return; + } + string label; - if (undo_action && _session) { + if (undo_action) { if (_session->undo_depth() == 0) { label = S_("Command|Undo"); + undo_action->set_sensitive(false); } else { label = string_compose(S_("Command|Undo (%1)"), _session->next_undo()); + undo_action->set_sensitive(true); } undo_action->property_label() = label; } - if (redo_action && _session) { + if (redo_action) { if (_session->redo_depth() == 0) { label = _("Redo"); redo_action->set_sensitive (false); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 301fd47aaa..276500d026 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -162,10 +162,6 @@ Editor::undo (uint32_t n) if (_session) { _session->undo (n); - if (_session->undo_depth() == 0) { - undo_action->set_sensitive(false); - } - redo_action->set_sensitive(true); begin_selection_op_history (); } } @@ -186,11 +182,7 @@ Editor::redo (uint32_t n) paste_count = 0; if (_session) { - _session->redo (n); - if (_session->redo_depth() == 0) { - redo_action->set_sensitive(false); - } - undo_action->set_sensitive(true); + _session->redo (n); begin_selection_op_history (); } }