diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 893f94831b..bcc37dde51 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -773,7 +773,11 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot /* tell sources we're saving first, in case they write out to a new file * which should be saved with the state rather than the old one */ for (SourceMap::const_iterator i = sources.begin(); i != sources.end(); ++i) { - i->second->session_saved(); + try { + i->second->session_saved(); + } catch (Evoral::SMF::FileError& e) { + error << string_compose ("Could not write to MIDI file %1; MIDI data not saved.", e.file_name ()) << endmsg; + } } tree.set_root (&get_state()); diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp index 67ea42fe7d..8bd05444c4 100644 --- a/libs/evoral/evoral/SMF.hpp +++ b/libs/evoral/evoral/SMF.hpp @@ -38,7 +38,13 @@ namespace Evoral { class SMF { public: class FileError : public std::exception { + public: + FileError (std::string const & n) : _file_name (n) {} + ~FileError () throw () {} const char* what() const throw() { return "Unknown SMF error"; } + std::string file_name () const { return _file_name; } + private: + std::string _file_name; }; SMF() : _smf(0), _smf_track(0), _empty(true) {}; diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp index ffc21a947f..b84507818c 100644 --- a/libs/evoral/src/SMF.cpp +++ b/libs/evoral/src/SMF.cpp @@ -354,11 +354,11 @@ SMF::end_write() THROW_FILE_ERROR PBD::StdioFileDescriptor d (_file_path, "w+"); FILE* f = d.allocate (); if (f == 0) { - throw FileError (); + throw FileError (_file_path); } if (smf_save(_smf, f) != 0) { - throw FileError(); + throw FileError (_file_path); } }