13
0

prevent crash when loading midi port info about ports that no longer exist

This commit is contained in:
Paul Davis 2017-04-18 14:14:17 +01:00
parent 5dce10500c
commit a372fcbe51

View File

@ -1207,12 +1207,19 @@ PortManager::fill_midi_port_info_locked ()
for (MidiPortInfo::iterator x = midi_port_info.begin(); x != midi_port_info.end(); ++x) { for (MidiPortInfo::iterator x = midi_port_info.begin(); x != midi_port_info.end(); ++x) {
PortEngine::PortHandle ph = _backend->get_port_by_name (x->first); PortEngine::PortHandle ph = _backend->get_port_by_name (x->first);
if (!ph) {
/* port info saved from some condition where this port
* existed, but no longer does (i.e. device unplugged
* at present)
*/
continue;
}
if (x->second.pretty_name != x->first) { if (x->second.pretty_name != x->first) {
/* name set in port info ... propagate */ /* name set in port info ... propagate */
_backend->set_port_property (ph, "http://jackaudio.org/metadata/pretty-name", x->second.pretty_name, string()); _backend->set_port_property (ph, "http://jackaudio.org/metadata/pretty-name", x->second.pretty_name, string());
} else { } else {
/* check with backend for pre-existing pretty name */ /* check with backend for pre-existing pretty name */
if (ph) {
string value; string value;
string type; string type;
if (0 == _backend->get_port_property (ph, if (0 == _backend->get_port_property (ph,
@ -1222,7 +1229,6 @@ PortManager::fill_midi_port_info_locked ()
} }
} }
} }
}
midi_info_dirty = false; midi_info_dirty = false;
} }