Fix border case where bank select controlers are last in midnam file.

Fix potential infinite loop in controller menu generation.


git-svn-id: svn://localhost/ardour2/branches/3.0@14001 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2013-01-26 22:30:34 +00:00
parent 84eee94b1e
commit 03e06e71d6

View file

@ -837,12 +837,8 @@ MidiTimeAxisView::build_controller_menu ()
for (ControlNameList::Controls::const_iterator c = name_list->controls().begin(); for (ControlNameList::Controls::const_iterator c = name_list->controls().begin();
c != name_list->controls().end();) { c != name_list->controls().end();) {
const uint16_t ctl = c->second->number(); const uint16_t ctl = c->second->number();
if (ctl == MIDI_CTL_MSB_BANK || ctl == MIDI_CTL_LSB_BANK) { if (ctl != MIDI_CTL_MSB_BANK && ctl != MIDI_CTL_LSB_BANK) {
/* Skip bank select controllers since they're handled specially */ /* Skip bank select controllers since they're handled specially */
/* FIXME: If this is the last control, the last submenu might be lost */
continue;
}
if (n_items == 0) { if (n_items == 0) {
/* Create a new submenu */ /* Create a new submenu */
ctl_menu = manage (new Menu); ctl_menu = manage (new Menu);
@ -854,10 +850,11 @@ MidiTimeAxisView::build_controller_menu ()
} else { } else {
add_single_channel_controller_item(ctl_items, ctl, c->second->name()); add_single_channel_controller_item(ctl_items, ctl, c->second->name());
} }
}
++c; ++c;
if (++n_items == 16 || c == name_list->controls().end()) { if (ctl_menu && (++n_items == 16 || c == name_list->controls().end())) {
/* Submenu has 16 items, add it to controller menu and reset */ /* Submenu has 16 items or we're done, add it to controller menu and reset */
items.push_back( items.push_back(
MenuElem(string_compose(_("Controllers %1-%2"), MenuElem(string_compose(_("Controllers %1-%2"),
(16 * n_groups), (16 * n_groups) + n_items - 1), (16 * n_groups), (16 * n_groups) + n_items - 1),