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.
This commit is contained in:
Caleb Potter 2022-03-04 14:43:27 -06:00 committed by Paul Davis
parent e89d85f776
commit 643342995d

View file

@ -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);
}