summaryrefslogtreecommitdiff
path: root/libs/ardour/region_factory.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-11-14 23:53:59 -0500
committerDavid Robillard <d@drobilla.net>2014-11-14 23:53:59 -0500
commitb52407043c71f9169a2a8171d07e4e1ade5f07a3 (patch)
tree4c6fc288fe3a058497f81998f02e7ecb52964a63 /libs/ardour/region_factory.cc
parent94954f852ead97bcda7afa548d543222733228ef (diff)
Fix crash when copying MIDI regions with midi-copy-is-fork is on (#6002).
Diffstat (limited to 'libs/ardour/region_factory.cc')
-rw-r--r--libs/ardour/region_factory.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc
index 9654a4b3de..7c9f4fd228 100644
--- a/libs/ardour/region_factory.cc
+++ b/libs/ardour/region_factory.cc
@@ -19,6 +19,7 @@
#include <inttypes.h>
+#include "pbd/basename.h"
#include "pbd/error.h"
#include "ardour/audioregion.h"
@@ -58,7 +59,17 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce)
} else if ((mr = boost::dynamic_pointer_cast<const MidiRegion>(region)) != 0) {
if (mr->session().config.get_midi_copy_is_fork()) {
- ret = mr->clone ();
+ /* What we really want to do here is what Editor::fork_region()
+ does via Session::create_midi_source_by_stealing_name(), but we
+ don't have a Track. We'll just live with the skipped number,
+ and store the ancestral name of sources so multiple clones
+ generates reasonable names that don't have too many suffixes. */
+ const std::string ancestor_name = mr->sources().front()->ancestor_name();
+ const std::string base = PBD::basename_nosuffix(ancestor_name);
+
+ boost::shared_ptr<MidiSource> source = mr->session().create_midi_source_for_session(base);
+ source->set_ancestor_name(mr->sources().front()->name());
+ ret = mr->clone(source);
} else {
ret = boost::shared_ptr<Region> (new MidiRegion (mr, 0));
}