summaryrefslogtreecommitdiff
path: root/libs/ardour/smf_source.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-09-15 12:38:54 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-09-15 14:09:12 -0400
commit9a3cf7a10bfad6fe2876867f211e44c808026247 (patch)
tree942bde7cd7f6f2b71c2e49e4daa7f436640611d3 /libs/ardour/smf_source.cc
parent596a9247bd6e5cc97b0bf3809721e1c56d872c1a (diff)
fix up condition where a MIDI filesource is marked empty, not found, and its _path member is not set correctly
Diffstat (limited to 'libs/ardour/smf_source.cc')
-rw-r--r--libs/ardour/smf_source.cc35
1 files changed, 30 insertions, 5 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 59f4c240d9..d09f4d561e 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -100,16 +100,15 @@ SMFSource::SMFSource (Session& s, const string& path)
{
/* note that origin remains empty */
- if (init (_path, false)) {
+ if (init (_path, true)) {
throw failed_constructor ();
}
assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS));
existence_check ();
- /* file is not opened until write */
-
if (_flags & Writable) {
+ /* file is not opened until write */
return;
}
@@ -139,8 +138,30 @@ SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist)
require it to exist if it was marked Empty.
*/
- if (init (_path, !(_flags & Source::Empty))) {
- throw failed_constructor ();
+ try {
+
+ if (init (_path, true)) {
+ throw failed_constructor ();
+ }
+
+ } catch (MissingSource& err) {
+
+ if (_flags & Source::Empty) {
+ /* we don't care that the file was not found, because
+ it was empty. But FileSource::init() will have
+ failed to set our _path correctly, so we have to do
+ this ourselves. Use the first entry in the search
+ path for MIDI files, which is assumed to be the
+ correct "main" location.
+ */
+ std::vector<string> sdirs = s.source_search_path (DataType::MIDI);
+ _path = Glib::build_filename (sdirs.front(), _path);
+ /* This might be important, too */
+ _file_is_new = true;
+ } else {
+ /* pass it on */
+ throw;
+ }
}
if (!(_flags & Source::Empty)) {
@@ -705,6 +726,10 @@ SMFSource::set_path (const string& p)
void
SMFSource::ensure_disk_file ()
{
+ if (!writable()) {
+ return;
+ }
+
if (_model) {
/* We have a model, so write it to disk; see MidiSource::session_saved
for an explanation of what we are doing here.