From 4facff3b8ea68cf8f90e63e9f41b27349b1a43d6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 30 Dec 2014 22:05:10 -0500 Subject: Gracefully handle MIDI parse failure. --- gtk2_ardour/sfdb_ui.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'gtk2_ardour/sfdb_ui.cc') diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 9ef39d0aaa..8e89ccf4b3 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -283,10 +283,15 @@ SoundFileBox::setup_labels (const string& filename) if (SMFSource::valid_midi_file (path)) { - boost::shared_ptr ms = - boost::dynamic_pointer_cast ( - SourceFactory::createExternal (DataType::MIDI, *_session, - path, 0, Source::Flag (0), false)); + boost::shared_ptr ms; + try { + ms = boost::dynamic_pointer_cast ( + 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 (_("Midi File Information")); -- cgit v1.2.3