- for (SourceList::const_iterator i = other->_master_sources.begin(); i != other->_master_sources.end(); ++i) {
- if (unique_srcs.find (*i) == unique_srcs.end()) {
- (*i)->GoingAway.connect (bind (mem_fun (*this, &Region::source_deleted), (*i)));
+Region::Region (boost::shared_ptr<const Region> other, nframes_t length, const string& name, layer_t layer, Flag flags)
+ : SessionObject(other->session(), name)
+ , _type (other->data_type())
+ , _pending_explicit_relayer (false)
+{
+ /* create a new Region exactly like another but starting at 0 in its sources */
+
+ _start = 0;
+ copy_stuff (other, 0, length, name, layer, flags);
+
+ _flags = Flag (_flags | DoNotSendPropertyChanges);
+
+ /* sync pos is relative to start of file. our start-in-file is now zero,
+ so set our sync position to whatever the the difference between
+ _start and _sync_pos was in the other region.
+
+ result is that our new sync pos points to the same point in our source(s)
+ as the sync in the other region did in its source(s).
+
+ since we start at zero in our source(s), it is not possible to use a sync point that
+ is before the start. reset it to _start if that was true in the other region.
+ */
+
+ if (other->flags() & SyncMarked) {
+ if (other->_start < other->_sync_position) {
+ /* sync pos was after the start point of the other region */
+ _sync_position = other->_sync_position - other->_start;
+ } else {
+ /* sync pos was before the start point of the other region. not possible here. */
+ _flags = Flag (_flags & ~SyncMarked);
+ _sync_position = _start;