fix assert for non-existing MIDI patch-names
authorRobin Gareus <robin@gareus.org>
Mon, 30 Dec 2013 15:24:27 +0000 (16:24 +0100)
committerRobin Gareus <robin@gareus.org>
Mon, 30 Dec 2013 15:24:27 +0000 (16:24 +0100)
typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = MIDI::Name::ChannelNameSet; typename boost::detail::sp_member_access<T>::type = MIDI::Name::ChannelNameSet*]: Assertion `px != 0' failed.

libs/midi++2/midnam_patch.cc

index bf22792f70a1319ff49100dbfae9eb2366d7f790..bd8bbfc42d95c271db592467b71bf00e7a582129 100644 (file)
@@ -542,7 +542,9 @@ MasterDeviceNames::channel_name_set_by_device_mode_and_channel(const std::string
 boost::shared_ptr<Patch> 
 MasterDeviceNames::find_patch(const std::string& mode, uint8_t channel, const PatchPrimaryKey& key) 
 {
-       return channel_name_set_by_device_mode_and_channel(mode, channel)->find_patch(key);
+       boost::shared_ptr<ChannelNameSet> cns = channel_name_set_by_device_mode_and_channel(mode, channel);
+       if (!cns) return boost::shared_ptr<Patch>();
+       return cns->find_patch(key);
 }
 
 boost::shared_ptr<ChannelNameSet>