+ Locations::LocationList all_locations = _locations->list ();
+ Locations::LocationList skips;
+
+ for (Locations::LocationList::iterator l = all_locations.begin(); l != all_locations.end(); ) {
+
+ if (!(*l)->is_skip ()) {
+ ++l;
+ continue;
+ }
+
+ /* don't test against self */
+
+ if (*l == loc) {
+ ++l;
+ continue;
+ }
+
+ switch (Evoral::coverage ((*l)->start(), (*l)->end(), loc->start(), loc->end())) {
+ case Evoral::OverlapInternal:
+ case Evoral::OverlapExternal:
+ case Evoral::OverlapStart:
+ case Evoral::OverlapEnd:
+ /* adjust new location to cover existing one */
+ loc->set_start (min (loc->start(), (*l)->start()));
+ loc->set_end (max (loc->end(), (*l)->end()));
+ /* we don't need this one any more */
+ _locations->remove (*l);
+ /* the location has been deleted, so remove reference to it in our local list */
+ l = all_locations.erase (l);
+ break;
+
+ case Evoral::OverlapNone:
+ skips.push_back (*l);
+ ++l;
+ break;
+ }
+ }
+
+ /* add the new one, which now covers the maximal appropriate range based on overlaps with existing skips */
+
+ skips.push_back (loc);
+
+ return skips;