From fad71ce748fd244611ffad397fd0c51ecbe72334 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 27 Aug 2021 16:52:34 -0600 Subject: [PATCH] when creating new MIDI sources, be sure that we create a stub file on disk These files will be removed at session close if they are still empty. Their existence prevents collisions across snapshots and likely some other wierdness that relied on file existence for various tests and conditions --- libs/ardour/smf_source.cc | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index dfaabc2c89..89b7e7ccab 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -82,17 +82,18 @@ SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags) _flags = Source::Flag (_flags | Empty); - /* file is not opened until write */ - - if (flags & Writable) { - return; + if (_flags & Writable) { + if (open_for_write ()) { + throw failed_constructor (); + } + /* no fd left open here */ + } else { + if (open (_path)) { + throw failed_constructor (); + } + _open = true; } - if (open (_path)) { - throw failed_constructor (); - } - - _open = true; } /** Constructor used for external-to-session files. File must exist. */ @@ -113,11 +114,6 @@ SMFSource::SMFSource (Session& s, const string& path) assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS)); existence_check (); - if (_flags & Writable) { - /* file is not opened until write */ - return; - } - if (open (_path)) { throw failed_constructor (); } @@ -172,17 +168,18 @@ SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist) if (!(_flags & Source::Empty)) { assert (Glib::file_test (_path, Glib::FILE_TEST_EXISTS)); existence_check (); + if (open (_path)) { + throw failed_constructor (); + } + _open = true; } else { assert (_flags & Source::Writable); - /* file will be opened on write */ - return; + if (open_for_write ()) { + throw failed_constructor (); + } + /* no fd left open here */ } - if (open (_path)) { - throw failed_constructor (); - } - - _open = true; } SMFSource::~SMFSource ()