From 024adf3a4d14b3bc9f473ed298d5d6c23b14c21e Mon Sep 17 00:00:00 2001 From: nick_m Date: Sat, 14 Nov 2015 03:14:23 +1100 Subject: Fix #6673 - another prematurely closed undo transaction. - add_midi_region used to commit, resulting in _region->set_position() adding a command when there was no current transaction. The sub-bug here was that repeatedly calling set_position() on the new region resulted in nonsensical automation movement after the drag. --- gtk2_ardour/editor_drag.cc | 14 ++++++++------ gtk2_ardour/editor_drag.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'gtk2_ardour') diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index e84da9dc2a..81cc038b0e 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -510,7 +510,7 @@ Drag::show_verbose_cursor_text (string const & text) } boost::shared_ptr -Drag::add_midi_region (MidiTimeAxisView* view) +Drag::add_midi_region (MidiTimeAxisView* view, bool commit) { if (_editor->session()) { const TempoMap& map (_editor->session()->tempo_map()); @@ -520,7 +520,7 @@ Drag::add_midi_region (MidiTimeAxisView* view) might be wrong. */ framecnt_t len = m.frames_per_bar (map.tempo_at (pos), _editor->session()->frame_rate()); - return view->add_region (grab_frame(), len, true); + return view->add_region (grab_frame(), len, commit); } return boost::shared_ptr(); @@ -2303,13 +2303,14 @@ void RegionCreateDrag::motion (GdkEvent* event, bool first_move) { if (first_move) { - _region = add_midi_region (_view); + _editor->begin_reversible_command (_("create region")); + _region = add_midi_region (_view, false); _view->playlist()->freeze (); } else { if (_region) { framepos_t const f = adjusted_current_frame (event); if (f < grab_frame()) { - _region->set_position (f); + _region->set_initial_position (f); } /* Don't use a zero-length region, and subtract 1 frame from the snapped length @@ -2329,9 +2330,10 @@ void RegionCreateDrag::finished (GdkEvent*, bool movement_occurred) { if (!movement_occurred) { - add_midi_region (_view); + add_midi_region (_view, true); } else { _view->playlist()->thaw (); + _editor->commit_reversible_command(); } } @@ -4643,7 +4645,7 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred) /* MIDI track */ if (_editor->selection->empty() && _editor->mouse_mode == MouseDraw) { /* nothing selected */ - add_midi_region (mtv); + add_midi_region (mtv, true); do_deselect = false; } } diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index d8f667529e..cd1b0c2474 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -246,7 +246,7 @@ protected: /* sets snap delta from unsnapped pos */ void setup_snap_delta (framepos_t pos); - boost::shared_ptr add_midi_region (MidiTimeAxisView*); + boost::shared_ptr add_midi_region (MidiTimeAxisView*, bool commit); void show_verbose_cursor_time (framepos_t); void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0); -- cgit v1.2.3