- for (SourceList::iterator i=srcs.begin(); i != srcs.end(); ++i) {
- _sources.push_back (*i);
- (*i)->GoingAway.connect (bind (mem_fun (*this, &Region::source_deleted), (*i)));
- unique_srcs.insert (*i);
+/** Create a new Region from part of an existing one */
+Region::Region (boost::shared_ptr<const Region> other, nframes_t offset, nframes_t length, const string& name, layer_t layer, Flag flags)
+ : SessionObject(other->session(), name)
+ , _type (other->data_type())
+ , _pending_explicit_relayer (false)
+
+{
+ _start = other->_start + offset;
+ copy_stuff (other, offset, length, name, layer, flags);
+
+ _flags = Flag (_flags | DoNotSendPropertyChanges);
+
+ /* if the other region had a distinct sync point
+ set, then continue to use it as best we can.
+ otherwise, reset sync point back to start.
+ */
+
+ if (other->flags() & SyncMarked) {
+ if (other->_sync_position < _start) {
+ _flags = Flag (_flags & ~SyncMarked);
+ _sync_position = _start;
+ } else {
+ _sync_position = other->_sync_position;
+ }
+ } else {
+ _flags = Flag (_flags & ~SyncMarked);
+ _sync_position = _start;