From da89cd0c9b545c418fe2d6692844ff05779bb258 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 21 Dec 2010 17:03:16 +0000 Subject: Remove confuzzling offset_relative stuff from region construction (pre-properties "hangover"). This commit (in theory) only reorganizes code, not change actual functionality. RegionFactory now uses a distinct Region constructor for each case, which is a bit easier to wrap around. Note comment at region.cc:276, this case seems pretty weird to me (more hangover?). git-svn-id: svn://localhost/ardour2/branches/3.0@8320 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/region_factory.cc | 50 ++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 12 deletions(-) (limited to 'libs/ardour/region_factory.cc') diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc index 459f993676..4179ec95db 100644 --- a/libs/ardour/region_factory.cc +++ b/libs/ardour/region_factory.cc @@ -53,7 +53,7 @@ RegionFactory::create (boost::shared_ptr region, bool announce) if ((ar = boost::dynamic_pointer_cast(region)) != 0) { - AudioRegion* arn = new AudioRegion (ar, 0, true); + AudioRegion* arn = new AudioRegion (ar, 0); boost_debug_shared_ptr_mark_interesting (arn, "Region"); boost::shared_ptr arp (arn); @@ -61,7 +61,7 @@ RegionFactory::create (boost::shared_ptr region, bool announce) } else if ((mr = boost::dynamic_pointer_cast(region)) != 0) { - MidiRegion* mrn = new MidiRegion (mr, 0, true); + MidiRegion* mrn = new MidiRegion (mr, 0); boost::shared_ptr mrp (mrn); ret = boost::static_pointer_cast (mrp); @@ -86,20 +86,46 @@ RegionFactory::create (boost::shared_ptr region, bool announce) return ret; } -boost::shared_ptr -RegionFactory::create (boost::shared_ptr region, frameoffset_t offset, const PropertyList& plist, bool announce) -{ - return create (region, offset, true, plist, announce); -} - boost::shared_ptr RegionFactory::create (boost::shared_ptr region, const PropertyList& plist, bool announce) { - return create (region, 0, false, plist, announce); + boost::shared_ptr ret; + boost::shared_ptr other_a; + boost::shared_ptr other_m; + + if ((other_a = boost::dynamic_pointer_cast(region)) != 0) { + + AudioRegion* ar = new AudioRegion (other_a); + boost::shared_ptr arp (ar); + ret = boost::static_pointer_cast (arp); + + } else if ((other_m = boost::dynamic_pointer_cast(region)) != 0) { + + MidiRegion* mr = new MidiRegion (other_m); + boost::shared_ptr mrp (mr); + ret = boost::static_pointer_cast (mrp); + + } else { + fatal << _("programming error: RegionFactory::create() called with unknown Region type") + << endmsg; + /*NOTREACHED*/ + return boost::shared_ptr(); + } + + if (ret) { + ret->apply_changes (plist); + map_add (ret); + + if (announce) { + CheckNewRegion (ret); + } + } + + return ret; } boost::shared_ptr -RegionFactory::create (boost::shared_ptr region, frameoffset_t offset, bool offset_relative, const PropertyList& plist, bool announce) +RegionFactory::create (boost::shared_ptr region, frameoffset_t offset, const PropertyList& plist, bool announce) { boost::shared_ptr ret; boost::shared_ptr other_a; @@ -107,7 +133,7 @@ RegionFactory::create (boost::shared_ptr region, frameoffset_t offset, b if ((other_a = boost::dynamic_pointer_cast(region)) != 0) { - AudioRegion* ar = new AudioRegion (other_a, offset, offset_relative); + AudioRegion* ar = new AudioRegion (other_a, offset); boost_debug_shared_ptr_mark_interesting (ar, "Region"); boost::shared_ptr arp (ar); @@ -115,7 +141,7 @@ RegionFactory::create (boost::shared_ptr region, frameoffset_t offset, b } else if ((other_m = boost::dynamic_pointer_cast(region)) != 0) { - MidiRegion* mr = new MidiRegion (other_m, offset, offset_relative); + MidiRegion* mr = new MidiRegion (other_m, offset); boost::shared_ptr mrp (mr); ret = boost::static_pointer_cast (mrp); -- cgit v1.2.3