summaryrefslogtreecommitdiff
path: root/libs/ardour/region.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-02-26 20:37:54 +0000
committerCarl Hetherington <carl@carlh.net>2011-02-26 20:37:54 +0000
commit9d540e62157c556b797f6469f7b4a7932584a62a (patch)
treec7095d6558cccb5538c2dfa63eeedc7668edb123 /libs/ardour/region.cc
parentd8657a4ab83ee96c21ce4620e9daca789d76e164 (diff)
Fix ordering of set position / length when trimming the start of MIDI regions. Fixes most of the rest of #3789.
git-svn-id: svn://localhost/ardour2/branches/3.0@8967 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/region.cc')
-rw-r--r--libs/ardour/region.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index 7fb94bb177..873e265225 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -920,13 +920,15 @@ Region::trim_to_internal (framepos_t position, framecnt_t length, void */*src*/)
_start = new_start;
what_changed.add (Properties::start);
}
- if (_length != length) {
- if (!property_changes_suspended()) {
- _last_length = _length;
- }
- set_length_internal (length);
- what_changed.add (Properties::length);
- }
+
+ /* Set position before length, otherwise for MIDI regions this bad thing happens:
+ * 1. we call set_length_internal; length in beats is computed using the region's current
+ * (soon-to-be old) position
+ * 2. we call set_position_internal; position is set and length in frames re-computed using
+ * length in beats from (1) but at the new position, which is wrong if the region
+ * straddles a tempo/meter change.
+ */
+
if (_position != position) {
if (!property_changes_suspended()) {
_last_position = _position;
@@ -934,6 +936,14 @@ Region::trim_to_internal (framepos_t position, framecnt_t length, void */*src*/)
set_position_internal (position, true);
what_changed.add (Properties::position);
}
+
+ if (_length != length) {
+ if (!property_changes_suspended()) {
+ _last_length = _length;
+ }
+ set_length_internal (length);
+ what_changed.add (Properties::length);
+ }
_whole_file = false;