From 643342995dfd0bd32c031a6f81a8112e0f11b5fe Mon Sep 17 00:00:00 2001 From: Caleb Potter Date: Fri, 4 Mar 2022 14:43:27 -0600 Subject: [PATCH] fixes issue where MCP controller strips got stranded switching banks This commit fixes an issue where if your controller was currently on a bank not near the first few tracks, and you then deleted tracks, the controller bank buttons would appear unresponsive because of the "if (initial >= sorted.size())" check in switch_banks(). This would occur when the difference between the _initial_bank and whatever sorted.size() returns was greater than or equal to strip_cnt. For example, if your _initial_bank was 48, your strip_cnt was 24 and you had 24 tracks after the deletion, then the above conditional would evaluate to true and exit out of switch_banks BEFORE actually switching the bank, effectively stranding the controller unless you added enough tracks back. --- libs/surfaces/mackie/mcp_buttons.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/surfaces/mackie/mcp_buttons.cc b/libs/surfaces/mackie/mcp_buttons.cc index 2c47d49078..5aded2898f 100644 --- a/libs/surfaces/mackie/mcp_buttons.cc +++ b/libs/surfaces/mackie/mcp_buttons.cc @@ -111,8 +111,14 @@ MackieControlProtocol::left_press (Button &) DEBUG_TRACE (DEBUG::MackieControl, string_compose ("bank left with current initial = %1 nstrips = %2 tracks/busses = %3\n", _current_initial_bank, strip_cnt, sorted.size())); + if (_current_initial_bank > 0) { - (void) switch_banks ((_current_initial_bank - 1) / strip_cnt * strip_cnt); + uint32_t initial = (_current_initial_bank - 1) / strip_cnt * strip_cnt; + while (initial >= sorted.size()) + { + initial -= strip_cnt; + } + (void) switch_banks (initial); } else { (void) switch_banks (0); }