Gracefully handle MIDI parse failure.

This commit is contained in:
David Robillard 2014-12-30 22:05:10 -05:00
parent f499f4cfd2
commit 4facff3b8e
1 changed files with 9 additions and 4 deletions

View File

@ -283,10 +283,15 @@ SoundFileBox::setup_labels (const string& filename)
if (SMFSource::valid_midi_file (path)) {
boost::shared_ptr<SMFSource> ms =
boost::dynamic_pointer_cast<SMFSource> (
SourceFactory::createExternal (DataType::MIDI, *_session,
path, 0, Source::Flag (0), false));
boost::shared_ptr<SMFSource> ms;
try {
ms = boost::dynamic_pointer_cast<SMFSource> (
SourceFactory::createExternal (DataType::MIDI, *_session,
path, 0, Source::Flag (0), false));
} catch (const std::exception& e) {
error << string_compose(_("Could not read file: %1 (%2)."),
path, e.what()) << endmsg;
}
preview_label.set_markup (_("<b>Midi File Information</b>"));