13
0

if a binding map specifies controllables that don't exist in the session, drop those bindings so that we don't crash from having bindings without controllables (should fix #4256)

git-svn-id: svn://localhost/ardour2/branches/3.0@9973 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-08-10 15:57:03 +00:00
parent 38de5c169f
commit 0a07cca64c

View File

@ -730,9 +730,11 @@ void
GenericMidiControlProtocol::reset_controllables ()
{
Glib::Mutex::Lock lm2 (controllables_lock);
for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end(); ++iter) {
for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end(); ) {
MIDIControllable* existingBinding = (*iter);
MIDIControllables::iterator next = iter;
++next;
if (!existingBinding->learned()) {
ControllableDescriptor& desc (existingBinding->descriptor());
@ -741,9 +743,21 @@ GenericMidiControlProtocol::reset_controllables ()
desc.set_bank_offset (_current_bank * _bank_size);
}
/* its entirely possible that the session doesn't have
* the specified controllable (e.g. it has too few
* tracks). if we find this to be the case, drop any
* bindings that would be left without controllables.
*/
boost::shared_ptr<Controllable> c = session->controllable_by_descriptor (desc);
existingBinding->set_controllable (c.get());
if (c) {
existingBinding->set_controllable (c.get());
} else {
controllables.erase (iter);
}
}
iter = next;
}
}