- return create (region, 0, false, plist, announce);
+ boost::shared_ptr<Region> ret;
+ boost::shared_ptr<const AudioRegion> other_a;
+ boost::shared_ptr<const MidiRegion> other_m;
+
+ if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
+
+ ret = boost::shared_ptr<Region> (new AudioRegion (other_a));
+
+ } else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
+
+ ret = boost::shared_ptr<Region> (new MidiRegion (other_m));
+
+ } else {
+ fatal << _("programming error: RegionFactory::create() called with unknown Region type")
+ << endmsg;
+ /*NOTREACHED*/
+ return boost::shared_ptr<Region>();
+ }
+
+ if (ret) {
+ ret->apply_changes (plist);
+
+ 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);
+ }
+ }
+
+#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
+ // boost_debug_shared_ptr_mark_interesting (ret.get(), "Region");
+#endif
+ return ret;