From cd9c2cedfbfde21c0c4d04fc8f35065cc5eab135 Mon Sep 17 00:00:00 2001 From: nick_m Date: Wed, 28 Sep 2016 23:30:47 +1000 Subject: Prevent overwriting of MidiRegion length and length_beats during session load. - . --- libs/ardour/midi_region.cc | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'libs/ardour/midi_region.cc') diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 8868b7c681..644e473e03 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -206,8 +206,15 @@ MidiRegion::post_set (const PropertyChange& pc) Region::post_set (pc); if (pc.contains (Properties::length) && !pc.contains (Properties::length_beats)) { - /* update non-musically */ - update_length_beats (0); + /* we're called by Stateful::set_values() which sends a change + only if the value is different from _current. + session load means we can clobber length_beats here in error (not all properties differ from current), + so disallow (this has been set from XML state anyway). + */ + if (!_session.loading()) { + /* update non-musically */ + update_length_beats (0); + } } else if (pc.contains (Properties::start) && !pc.contains (Properties::start_beats)) { set_start_beats_from_start_frames (); } @@ -307,13 +314,16 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute, con update_length_beats (sub_num); } - if (position_lock_style() == AudioTime) { - _length_beats = Evoral::Beats (_session.tempo_map().quarter_note_at_frame (_position + _length) - _session.tempo_map().quarter_note_at_frame (_position)); - } else { - /* leave _length_beats alone, and change _length to reflect the state of things - at the new position (tempo map may dictate a different number of frames). - */ - Region::set_length_internal (_session.tempo_map().frame_at_pulse (pulse() + (_length_beats.val().to_double() / 4.0)) - _position, sub_num); + /* don't clobber _length and _length_beats if session loading.*/ + if (!_session.loading()) { + if (position_lock_style() == AudioTime) { + _length_beats = Evoral::Beats (_session.tempo_map().quarter_note_at_frame (_position + _length) - _session.tempo_map().quarter_note_at_frame (_position)); + } else { + /* leave _length_beats alone, and change _length to reflect the state of things + at the new position (tempo map may dictate a different number of frames). + */ + Region::set_length_internal (_session.tempo_map().frame_at_pulse (pulse() + (_length_beats.val().to_double() / 4.0)) - _position, sub_num); + } } } -- cgit v1.2.3