mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 12:16:30 +01:00
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
This commit is contained in:
parent
d901dbccc9
commit
d7c836dc07
3 changed files with 29 additions and 7 deletions
|
|
@ -64,6 +64,7 @@ public:
|
||||||
void destroy_model ();
|
void destroy_model ();
|
||||||
|
|
||||||
void flush_midi ();
|
void flush_midi ();
|
||||||
|
void ensure_disk_file ();
|
||||||
|
|
||||||
static void set_header_position_offset (framecnt_t offset, bool negative);
|
static void set_header_position_offset (framecnt_t offset, bool negative);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1314,13 +1314,8 @@ MidiDiskstream::steal_write_sources()
|
||||||
{
|
{
|
||||||
list<boost::shared_ptr<Source> > ret;
|
list<boost::shared_ptr<Source> > ret;
|
||||||
|
|
||||||
/* put some data on the disk, even if its just a header for an empty file.
|
/* put some data on the disk, even if its just a header for an empty file */
|
||||||
XXX should we not have a more direct method for doing this? Maybe not
|
boost::dynamic_pointer_cast<SMFSource> (_write_source)->ensure_disk_file ();
|
||||||
since we don't want to mess around with the model/disk relationship
|
|
||||||
that the Source has to pay attention to.
|
|
||||||
*/
|
|
||||||
|
|
||||||
boost::dynamic_pointer_cast<MidiSource>(_write_source)->session_saved ();
|
|
||||||
|
|
||||||
/* never let it go away */
|
/* never let it go away */
|
||||||
_write_source->mark_nonremovable ();
|
_write_source->mark_nonremovable ();
|
||||||
|
|
|
||||||
|
|
@ -578,3 +578,29 @@ SMFSource::set_path (const string& p)
|
||||||
FileSource::set_path (p);
|
FileSource::set_path (p);
|
||||||
SMF::set_path (_path);
|
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 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue