From 0f4d61ab30fad5b34729256ed83a41955f1c93e6 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 3 Jan 2017 22:09:27 +0000 Subject: [PATCH] MidiRegion::clone() needs to ensure that the model is loaded before calling MidiSource::write_to() --- libs/ardour/midi_region.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 9b01b03f16..bb02a79fdd 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -178,10 +178,18 @@ MidiRegion::clone (boost::shared_ptr newsrc) const Evoral::Beats const bend = bfc.from (_start + _length); { + boost::shared_ptr ms = midi_source(0); + Source::Lock lm (ms->mutex()); + + if (!ms->model()) { + ms->load_model (lm); + } + /* Lock our source since we'll be reading from it. write_to() will - take a lock on newsrc. */ - Source::Lock lm (midi_source(0)->mutex()); - if (midi_source(0)->write_to (lm, newsrc, bbegin, bend)) { + take a lock on newsrc. + */ + + if (ms->write_to (lm, newsrc, bbegin, bend)) { return boost::shared_ptr (); } }