diff --git a/libs/ardour/ardour/route_group.h b/libs/ardour/ardour/route_group.h index 78a3102565..6fec1158c5 100644 --- a/libs/ardour/ardour/route_group.h +++ b/libs/ardour/ardour/route_group.h @@ -145,6 +145,7 @@ class LIBARDOUR_API RouteGroup : public SessionObject void assign_master (boost::shared_ptr); void unassign_master (boost::shared_ptr); + bool slaved () const; private: boost::shared_ptr routes; diff --git a/libs/ardour/route_group.cc b/libs/ardour/route_group.cc index ef1a232896..a42f90a113 100644 --- a/libs/ardour/route_group.cc +++ b/libs/ardour/route_group.cc @@ -562,6 +562,10 @@ RouteGroup::push_to_groups () void RouteGroup::assign_master (boost::shared_ptr master) { + if (!routes || routes->empty()) { + return; + } + boost::shared_ptr front = routes->front (); if (!front) { @@ -572,16 +576,20 @@ RouteGroup::assign_master (boost::shared_ptr master) return; } - if (!front->slaved()) { + bool cancel_master_controls = false; + if (!front->slaved()) { pre_master_gain = is_gain (); pre_master_solo = is_solo (); pre_master_mute = is_mute (); + cancel_master_controls = true; + } - for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) { - (*r)->assign (master); - } + for (RouteList::iterator r = routes->begin(); r != routes->end(); ++r) { + (*r)->assign (master); + } + if (cancel_master_controls) { set_gain (false); set_solo (false); set_mute (false); @@ -591,6 +599,10 @@ RouteGroup::assign_master (boost::shared_ptr master) void RouteGroup::unassign_master (boost::shared_ptr master) { + if (!routes || routes->empty()) { + return; + } + boost::shared_ptr front = routes->front (); if (!front) { @@ -611,3 +623,13 @@ RouteGroup::unassign_master (boost::shared_ptr master) set_mute (pre_master_mute); } } + +bool +RouteGroup::slaved () const +{ + if (!routes || routes->empty()) { + return false; + } + + return routes->front()->slaved (); +}