diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-13 10:29:07 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-14 13:05:08 -0400 |
commit | 0d5f4c553a7365612a44e1e0997a6d0e14d8b7ff (patch) | |
tree | d7031e5df3cbd6cae2b91630405e5f342d66f0e7 /gtk2_ardour | |
parent | 384c0a9facf1bfecc783ac048dbb0bae4ad901fd (diff) |
dramatic change in logic and naming for operations related to adding a MIDI region on demand and cloning/unlinking
Existing code would cause data loss due to creation of two Source objects referring the same path, one with removable flags and one without. Careful code review suggested a variety of thinkos, function naming problems and other confusion that caused this. I have tried ot extensively comment what is going on with these operations, because it is one key area in which MIDI differs from audio: with audio, capture is the only way to add a new audio region, but for MIDI there are GUI input events that can add a new region.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/editor_ops.cc | 17 | ||||
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 3 |
2 files changed, 12 insertions, 8 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 1a818f1c71..a2eae60052 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4772,12 +4772,17 @@ Editor::fork_region () MidiRegionView* const mrv = dynamic_cast<MidiRegionView*>(*r); if (mrv) { - boost::shared_ptr<Playlist> playlist = mrv->region()->playlist(); - boost::shared_ptr<MidiRegion> newregion = mrv->midi_region()->clone (); - - playlist->clear_changes (); - playlist->replace_region (mrv->region(), newregion, mrv->region()->position()); - _session->add_command(new StatefulDiffCommand (playlist)); + try { + boost::shared_ptr<Playlist> playlist = mrv->region()->playlist(); + boost::shared_ptr<MidiSource> new_source = _session->create_midi_source_by_stealing_name (mrv->midi_view()->track()); + boost::shared_ptr<MidiRegion> newregion = mrv->midi_region()->clone (new_source); + + playlist->clear_changes (); + playlist->replace_region (mrv->region(), newregion, mrv->region()->position()); + _session->add_command(new StatefulDiffCommand (playlist)); + } catch (...) { + error << string_compose (_("Could not unlink %1"), mrv->region()->name()) << endmsg; + } } r = tmp; diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 54793d9904..aa057d98c6 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -1524,8 +1524,7 @@ MidiTimeAxisView::add_region (framepos_t pos, framecnt_t length, bool commit) real_editor->snap_to (pos, 0); - boost::shared_ptr<Source> src = _session->create_midi_source_for_session ( - view()->trackview().track().get(), view()->trackview().track()->name()); + boost::shared_ptr<Source> src = _session->create_midi_source_by_stealing_name (view()->trackview().track()); PropertyList plist; plist.add (ARDOUR::Properties::start, 0); |