mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-06 05:35:47 +01:00
Catch exception thrown by SMF code when it cannot write
to a file (#4640). git-svn-id: svn://localhost/ardour2/branches/3.0@11259 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
f9a3f741bf
commit
9237c7411c
3 changed files with 13 additions and 3 deletions
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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) {};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue