fix shared_ptr<Route> management in Mackie support so that deleted routes are destroyed
This commit is contained in:
parent
a232673454
commit
672528baf4
@ -394,7 +394,9 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
|
||||
uint32_t strip_cnt = n_strips (false); // do not include locked strips
|
||||
// in this count
|
||||
|
||||
if (initial >= sorted.size()) {
|
||||
if (initial >= sorted.size() && !force) {
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank target %1 exceeds route range %2\n",
|
||||
_current_initial_bank, sorted.size()));
|
||||
/* too high, we can't get there */
|
||||
return -1;
|
||||
}
|
||||
@ -403,6 +405,8 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
|
||||
/* no banking - not enough routes to fill all strips and we're
|
||||
* not at the first one.
|
||||
*/
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("less routes (%1) than strips (%2) and we're at the end already (%3)\n",
|
||||
sorted.size(), strip_cnt, _current_initial_bank));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -437,6 +441,14 @@ MackieControlProtocol::switch_banks (uint32_t initial, bool force)
|
||||
}
|
||||
|
||||
} else {
|
||||
/* all strips need to be reset */
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("clear all strips, bank target %1 is outside route range %2\n",
|
||||
_current_initial_bank, sorted.size()));
|
||||
for (Surfaces::iterator si = surfaces.begin(); si != surfaces.end(); ++si) {
|
||||
vector<boost::shared_ptr<Route> > routes;
|
||||
/* pass in an empty route list, so that all strips will be reset */
|
||||
(*si)->map_routes (routes);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1743,8 +1755,6 @@ MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr<Route
|
||||
set_flip_mode (Normal);
|
||||
}
|
||||
|
||||
boost::shared_ptr<Route> old_route = _subview_route;
|
||||
|
||||
if (!subview_mode_would_be_ok (sm, r)) {
|
||||
|
||||
if (r) {
|
||||
@ -1787,14 +1797,12 @@ MackieControlProtocol::set_subview_mode (SubViewMode sm, boost::shared_ptr<Route
|
||||
return -1;
|
||||
}
|
||||
|
||||
boost::shared_ptr<Route> old_route = _subview_route;
|
||||
|
||||
_subview_mode = sm;
|
||||
_subview_route = r;
|
||||
|
||||
if (r) {
|
||||
/* retain _subview_route even if it is reset to null implicitly */
|
||||
_subview_route = r;
|
||||
}
|
||||
|
||||
if (r != old_route) {
|
||||
if (_subview_route != old_route) {
|
||||
subview_route_connections.drop_connections ();
|
||||
|
||||
/* Catch the current subview route going away */
|
||||
|
@ -726,8 +726,7 @@ MackieControlProtocol::plugin_release (Button &)
|
||||
LedState
|
||||
MackieControlProtocol::eq_press (Button &)
|
||||
{
|
||||
boost::shared_ptr<Route> r = first_selected_route ();
|
||||
set_subview_mode (EQ, r);
|
||||
set_subview_mode (EQ, first_selected_route ());
|
||||
return none; /* led state handled by set_subview_mode() */
|
||||
|
||||
}
|
||||
@ -739,8 +738,7 @@ MackieControlProtocol::eq_release (Button &)
|
||||
LedState
|
||||
MackieControlProtocol::dyn_press (Button &)
|
||||
{
|
||||
boost::shared_ptr<Route> r = first_selected_route ();
|
||||
set_subview_mode (Dynamics, r);
|
||||
set_subview_mode (Dynamics, first_selected_route ());
|
||||
return none; /* led state handled by set_subview_mode() */
|
||||
}
|
||||
|
||||
@ -922,8 +920,7 @@ MackieControlProtocol::track_release (Mackie::Button&)
|
||||
Mackie::LedState
|
||||
MackieControlProtocol::send_press (Mackie::Button&)
|
||||
{
|
||||
boost::shared_ptr<Route> r = first_selected_route ();
|
||||
set_subview_mode (Sends, r);
|
||||
set_subview_mode (Sends, first_selected_route());
|
||||
return none; /* led state handled by set_subview_mode() */
|
||||
}
|
||||
Mackie::LedState
|
||||
|
@ -185,6 +185,7 @@ Strip::set_route (boost::shared_ptr<Route> r, bool /*with_messages*/)
|
||||
reset_saved_values ();
|
||||
|
||||
if (!r) {
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 Strip %2 mapped to null route\n", _surface->number(), _index));
|
||||
zero ();
|
||||
return;
|
||||
}
|
||||
|
@ -937,7 +937,7 @@ Surface::map_routes (const vector<boost::shared_ptr<Route> >& routes)
|
||||
vector<boost::shared_ptr<Route> >::const_iterator r;
|
||||
Strips::iterator s = strips.begin();
|
||||
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mapping %1 routes\n", routes.size()));
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mapping %1 routes to %2 strips\n", routes.size(), strips.size()));
|
||||
|
||||
for (r = routes.begin(); r != routes.end() && s != strips.end(); ++s) {
|
||||
|
||||
@ -953,6 +953,7 @@ Surface::map_routes (const vector<boost::shared_ptr<Route> >& routes)
|
||||
}
|
||||
|
||||
for (; s != strips.end(); ++s) {
|
||||
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip %1 being set to null route\n", (*s)->index()));
|
||||
(*s)->set_route (boost::shared_ptr<Route>());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user