X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=inline;f=libs%2Fardour%2Fregion_factory.cc;h=7c9f4fd228200ebb4d7f3e6dc169f4b180872f0c;hb=a2fbce0e7f31bdebf59bcea5282b4909c9e19837;hp=44f8c34ddd3be482fd5377805f83bce3371ae571;hpb=fb313fb1741a04f270fff3703967df572ac4fc45;p=ardour.git diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc index 44f8c34ddd..7c9f4fd228 100644 --- a/libs/ardour/region_factory.cc +++ b/libs/ardour/region_factory.cc @@ -19,6 +19,7 @@ #include +#include "pbd/basename.h" #include "pbd/error.h" #include "ardour/audioregion.h" @@ -58,7 +59,17 @@ RegionFactory::create (boost::shared_ptr region, bool announce) } else if ((mr = boost::dynamic_pointer_cast(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 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 (new MidiRegion (mr, 0)); } @@ -66,7 +77,7 @@ RegionFactory::create (boost::shared_ptr region, bool announce) } else { fatal << _("programming error: RegionFactory::create() called with unknown Region type") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } if (ret) { @@ -108,7 +119,7 @@ RegionFactory::create (boost::shared_ptr region, const PropertyList& pli } else { fatal << _("programming error: RegionFactory::create() called with unknown Region type") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ return boost::shared_ptr(); } @@ -149,7 +160,7 @@ RegionFactory::create (boost::shared_ptr region, frameoffset_t offset, c } else { fatal << _("programming error: RegionFactory::create() called with unknown Region type") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ return boost::shared_ptr(); } @@ -191,7 +202,7 @@ RegionFactory::create (boost::shared_ptr region, const SourceList& srcs, } else { fatal << _("programming error: RegionFactory::create() called with unknown Region type") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } if (ret) {