diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index ffca22c725..1018419c26 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -162,9 +162,8 @@ class Playlist : public SessionObject, bool explicit_relayering () const { return _explicit_relayering; } - void set_explicit_relayering (bool e) { - _explicit_relayering = e; - } + + void set_explicit_relayering (bool e); protected: friend class Session; diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index d63b643d2d..f74eb1001f 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -2465,4 +2465,24 @@ Playlist::foreach_region (sigc::slot > s) } } - +void +Playlist::set_explicit_relayering (bool e) +{ + if (e == false && _explicit_relayering == true) { + + /* We are changing from explicit to implicit relayering; layering may have been changed whilst + we were in explicit mode, and we don't want that to be undone next time an implicit relayer + occurs. Hence now we'll set up region last_layer_op values so that an implicit relayer + at this point would keep regions on the same layers. + + From then on in, it's just you and your towel. + */ + + RegionLock rl (this); + for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { + (*i)->set_last_layer_op ((*i)->layer ()); + } + } + + _explicit_relayering = e; +}