From a3fdb544eeef3b61d465d9f574cd089ed13a1f24 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 2 Dec 2022 21:44:22 +0100 Subject: [PATCH] Fix copying MIDI regions w/automation This fixes a bug introduced in d06a0d9c9d2. The MIDI data has to be written first, otherwise the CC-event do not exit and MidiModel::source_interpolation_changed() crashes. --- libs/ardour/midi_region.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 1b6955dab3..85daf49792 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -161,19 +161,20 @@ MidiRegion::clone (boost::shared_ptr newsrc, ThawList* tl) const node.set_property (X_("flags"), newsrc->flags ()); node.set_property (X_("take-id"), newsrc->take_id()); - /* compare to SMFSource::set_state */ - newsrc->MidiSource::set_state (node, Stateful::current_state_version); - newsrc->Source::set_state (node, Stateful::current_state_version); - delete &node; - /* Lock our source since we'll be reading from it. write_to() will take a lock on newsrc. */ Source::ReaderLock lm (ms->mutex()); if (ms->write_to (lm, newsrc, Temporal::Beats(), std::numeric_limits::max())) { + delete &node; return boost::shared_ptr (); } + + /* compare to SMFSource::set_state */ + newsrc->MidiSource::set_state (node, Stateful::current_state_version); + newsrc->Source::set_state (node, Stateful::current_state_version); + delete &node; } PropertyList plist (derive_properties ());