From a445e8277640b5a59aa46b85599444243d9ddf4d Mon Sep 17 00:00:00 2001 From: nick_m Date: Mon, 6 Mar 2017 01:01:37 +1100 Subject: fix undo if a midi region start trim changed the source offset. - this diffs all playlists that use the same source. - the secons part hould be a no-op, but needs testing (trim drag undo on audio and midi regions) --- gtk2_ardour/editor_drag.cc | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'gtk2_ardour/editor_drag.cc') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 1538457f7e..0fa7b69bad 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -40,6 +40,7 @@ #include "ardour/profile.h" #include "ardour/region_factory.h" #include "ardour/session.h" +#include "ardour/session_playlists.h" #include "canvas/canvas.h" #include "canvas/scroll_group.h" @@ -2988,6 +2989,21 @@ TrimDrag::motion (GdkEvent* event, bool first_move) if (insert_result.second) { pl->freeze(); } + + MidiRegionView* const mrv = dynamic_cast (rv); + /* a MRV start trim may change the source length. ensure we cover all playlists here */ + if (mrv && _operation == StartTrim) { + vector > all_playlists; + _editor->session()->playlists->get (all_playlists); + for (vector >::iterator x = all_playlists.begin(); x != all_playlists.end(); ++x) { + if ((*x)->uses_source (rv->region()->source(0))) { + insert_result = _editor->motion_frozen_playlists.insert (*x); + if (insert_result.second) { + pl->freeze(); + } + } + } + } } } @@ -3136,29 +3152,22 @@ TrimDrag::finished (GdkEvent* event, bool movement_occurred) if (!_editor->selection->selected (_primary)) { _primary->thaw_after_trim (); } else { - - set > diffed_playlists; - for (list::const_iterator i = _views.begin(); i != _views.end(); ++i) { i->view->thaw_after_trim (); i->view->enable_display (true); - - /* Trimming one region may affect others on the playlist, so we need - to get undo Commands from the whole playlist rather than just the - region. Use diffed_playlists to make sure we don't diff a given - playlist more than once. - */ - boost::shared_ptr p = i->view->region()->playlist (); - if (diffed_playlists.find (p) == diffed_playlists.end()) { - vector cmds; - p->rdiff (cmds); - _editor->session()->add_commands (cmds); - diffed_playlists.insert (p); - } } } for (set >::iterator p = _editor->motion_frozen_playlists.begin(); p != _editor->motion_frozen_playlists.end(); ++p) { + /* Trimming one region may affect others on the playlist, so we need + to get undo Commands from the whole playlist rather than just the + region. Use motion_frozen_playlists (a set) to make sure we don't + diff a given playlist more than once. + */ + + vector cmds; + (*p)->rdiff (cmds); + _editor->session()->add_commands (cmds); (*p)->thaw (); } -- cgit v1.2.3