summaryrefslogtreecommitdiff
path: root/libs/ardour/smf_source.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-05-08 23:45:33 +0000
committerCarl Hetherington <carl@carlh.net>2011-05-08 23:45:33 +0000
commitd7c836dc07c657efda2651435125162791c29fd4 (patch)
tree512f84c0687910776ea8c04d2bc7e70bc839e651 /libs/ardour/smf_source.cc
parentd901dbccc912314b54494fab068785c188884fe4 (diff)
Ensure that empty drag-created MIDI regions get a file on disk so that there aren't missing file errors on reload (#4024).
git-svn-id: svn://localhost/ardour2/branches/3.0@9486 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/smf_source.cc')
-rw-r--r--libs/ardour/smf_source.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc
index 90ee20ab66..2a02e50da7 100644
--- a/libs/ardour/smf_source.cc
+++ b/libs/ardour/smf_source.cc
@@ -578,3 +578,29 @@ SMFSource::set_path (const string& p)
FileSource::set_path (p);
SMF::set_path (_path);
}
+
+/** Ensure that this source has some file on disk, even if it's just a SMF header */
+void
+SMFSource::ensure_disk_file ()
+{
+ if (_model) {
+ /* We have a model, so write it to disk; see MidiSource::session_saved
+ for an explanation of what we are doing here.
+ */
+ boost::shared_ptr<MidiModel> mm = _model;
+ _model.reset ();
+ mm->sync_to_source ();
+ _model = mm;
+ } else {
+ /* No model; if it's not already open, it's an empty source, so create
+ and open it for writing.
+ */
+ if (!_open) {
+ open_for_write ();
+ }
+
+ /* Flush, which will definitely put something on disk */
+ flush_midi ();
+ }
+}
+