+ if (copy.size() == 0) {
+ copy.push_front((*i));
+ i = tmp;
+ continue;
+ }
+
+ RegionViewList::iterator k = copy.begin();
+ RegionViewList::iterator l = copy.end();
+ l--;
+
+ if ((*i)->region()->layer() <= (*k)->region()->layer()) {
+ copy.push_front((*i));
+ i = tmp;
+ continue;
+ } else if ((*i)->region()->layer() >= (*l)->region()->layer()) {
+ copy.push_back((*i));
+ i = tmp;
+ continue;
+ }
+
+ for (RegionViewList::iterator j = copy.begin(); j != copy.end(); ++j) {
+ if ((*j)->region()->layer() >= (*i)->region()->layer()) {
+ copy.insert(j, (*i));
+ break;
+ }
+ }
+
+ i = tmp;
+ }
+
+ // Fix canvas layering by raising each in the sorted list order
+ for (RegionViewList::iterator i = copy.begin(); i != copy.end(); ++i) {
+ region_layered (*i);
+ }
+}
+
+void
+StreamView::playlist_modified_weak (boost::weak_ptr<Diskstream> ds)
+{
+ boost::shared_ptr<Diskstream> sp (ds.lock());
+ if (sp) {
+ playlist_modified (sp);
+ }
+}
+
+void
+StreamView::playlist_modified (boost::shared_ptr<Diskstream> ds)
+{
+ /* we do not allow shared_ptr<T> to be bound to slots */
+ ENSURE_GUI_THREAD (bind (mem_fun (*this, &StreamView::playlist_modified_weak), ds));
+
+ /* update layers count and the y positions and heights of our regions */
+ if (ds->playlist()) {
+ _layers = ds->playlist()->top_layer() + 1;
+ update_contents_height ();
+ update_coverage_frames ();
+ redisplay_diskstream ();
+ }
+}
+
+void
+StreamView::playlist_changed_weak (boost::weak_ptr<Diskstream> ds)
+{
+ boost::shared_ptr<Diskstream> sp (ds.lock());
+ if (sp) {
+ playlist_changed (sp);
+ }