X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fregion_factory.cc;h=33c714cd1d80c8d3bb337e9f448cf5a7b528865a;hb=f269e39115934c8e48dbc66e495d8cfdba1e70f0;hp=9654a4b3de530a6f78926aa066e826d983e1275f;hpb=592bfdd3f4af9463e2e6a691d7240839ba50d61d;p=ardour.git diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc index 9654a4b3de..33c714cd1d 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)); } @@ -72,7 +83,7 @@ RegionFactory::create (boost::shared_ptr region, bool announce) if (ret) { ret->set_name (new_region_name(ret->name())); ret->set_position (region->position()); - + if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) { ret->set_position_lock_style (MusicTime); } @@ -118,7 +129,7 @@ RegionFactory::create (boost::shared_ptr region, const PropertyList& pli if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) { ret->set_position_lock_style (MusicTime); } - + if (announce) { map_add (ret); CheckNewRegion (ret); @@ -244,7 +255,7 @@ RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool a if (ret->session().config.get_glue_new_regions_to_bars_and_beats ()) { ret->set_position_lock_style (MusicTime); } - + if (announce) { map_add (ret); CheckNewRegion (ret); @@ -291,7 +302,7 @@ RegionFactory::create (SourceList& srcs, const XMLNode& node) /* Don't fiddle with position_lock_style here as the region description is coming from XML. */ - + CheckNewRegion (ret); } } @@ -331,7 +342,7 @@ RegionFactory::map_remove (boost::weak_ptr w) if (!r) { return; } - + Glib::Threads::Mutex::Lock lm (region_map_lock); RegionMap::iterator i = region_map.find (r->id()); @@ -438,7 +449,7 @@ RegionFactory::rename_in_region_name_maps (boost::shared_ptr region) update_region_name_number_map (region); Glib::Threads::Mutex::Lock lm (region_name_maps_mutex); - + map::iterator i = region_name_map.begin(); while (i != region_name_map.end() && i->second != region->id ()) { ++i; @@ -641,7 +652,7 @@ RegionFactory::remove_regions_using_source (boost::shared_ptr src) RegionMap::iterator j = i; ++j; - + if (i->second->uses_source (src)) { remove_from_region_name_map (i->second->name ()); region_map.erase (i);