13
0

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.
This commit is contained in:
nick_m 2015-11-14 03:14:23 +11:00
parent 6210b63a13
commit 024adf3a4d
2 changed files with 9 additions and 7 deletions

View File

@ -510,7 +510,7 @@ Drag::show_verbose_cursor_text (string const & text)
} }
boost::shared_ptr<Region> boost::shared_ptr<Region>
Drag::add_midi_region (MidiTimeAxisView* view) Drag::add_midi_region (MidiTimeAxisView* view, bool commit)
{ {
if (_editor->session()) { if (_editor->session()) {
const TempoMap& map (_editor->session()->tempo_map()); const TempoMap& map (_editor->session()->tempo_map());
@ -520,7 +520,7 @@ Drag::add_midi_region (MidiTimeAxisView* view)
might be wrong. might be wrong.
*/ */
framecnt_t len = m.frames_per_bar (map.tempo_at (pos), _editor->session()->frame_rate()); 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<Region>(); return boost::shared_ptr<Region>();
@ -2303,13 +2303,14 @@ void
RegionCreateDrag::motion (GdkEvent* event, bool first_move) RegionCreateDrag::motion (GdkEvent* event, bool first_move)
{ {
if (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 (); _view->playlist()->freeze ();
} else { } else {
if (_region) { if (_region) {
framepos_t const f = adjusted_current_frame (event); framepos_t const f = adjusted_current_frame (event);
if (f < grab_frame()) { 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 /* 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) RegionCreateDrag::finished (GdkEvent*, bool movement_occurred)
{ {
if (!movement_occurred) { if (!movement_occurred) {
add_midi_region (_view); add_midi_region (_view, true);
} else { } else {
_view->playlist()->thaw (); _view->playlist()->thaw ();
_editor->commit_reversible_command();
} }
} }
@ -4643,7 +4645,7 @@ RubberbandSelectDrag::finished (GdkEvent* event, bool movement_occurred)
/* MIDI track */ /* MIDI track */
if (_editor->selection->empty() && _editor->mouse_mode == MouseDraw) { if (_editor->selection->empty() && _editor->mouse_mode == MouseDraw) {
/* nothing selected */ /* nothing selected */
add_midi_region (mtv); add_midi_region (mtv, true);
do_deselect = false; do_deselect = false;
} }
} }

View File

@ -246,7 +246,7 @@ protected:
/* sets snap delta from unsnapped pos */ /* sets snap delta from unsnapped pos */
void setup_snap_delta (framepos_t pos); void setup_snap_delta (framepos_t pos);
boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*); boost::shared_ptr<ARDOUR::Region> add_midi_region (MidiTimeAxisView*, bool commit);
void show_verbose_cursor_time (framepos_t); void show_verbose_cursor_time (framepos_t);
void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0); void show_verbose_cursor_duration (framepos_t, framepos_t, double xoffset = 0);