summaryrefslogtreecommitdiff
path: root/libs/ardour/location.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-07-15 00:24:50 +0000
committerCarl Hetherington <carl@carlh.net>2010-07-15 00:24:50 +0000
commitebe95f126523f8d7e4a2be03e5ba05d623be54d7 (patch)
tree481f5e78110b464715746a8d8f32775c4d7ab53d /libs/ardour/location.cc
parentdd336bfb8ce17e1c9740a6a0441d1a64030e010b (diff)
Fix setting of loop region start/end at the same time. Fixes #3314.
git-svn-id: svn://localhost/ardour2/branches/3.0@7418 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/location.cc')
-rw-r--r--libs/ardour/location.cc34
1 files changed, 26 insertions, 8 deletions
diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc
index 93b6b5c5fa..3f62d8949d 100644
--- a/libs/ardour/location.cc
+++ b/libs/ardour/location.cc
@@ -82,15 +82,21 @@ Location::operator= (const Location& other)
return this;
}
+/** Set start position.
+ * @param s New start.
+ * @param force true to force setting, even if the given new start is after the current end.
+ */
int
-Location::set_start (nframes64_t s)
+Location::set_start (nframes64_t s, bool force)
{
if (_locked) {
return -1;
}
- if (((is_auto_punch() || is_auto_loop()) && s >= _end) || (!is_mark() && s > _end)) {
- return -1;
+ if (!force) {
+ if (((is_auto_punch() || is_auto_loop()) && s >= _end) || (!is_mark() && s > _end)) {
+ return -1;
+ }
}
if (is_mark()) {
@@ -115,15 +121,21 @@ Location::set_start (nframes64_t s)
return 0;
}
+/** Set end position.
+ * @param s New end.
+ * @param force true to force setting, even if the given new start is after the current end.
+ */
int
-Location::set_end (nframes64_t e)
+Location::set_end (nframes64_t e, bool force)
{
if (_locked) {
return -1;
}
- if (((is_auto_punch() || is_auto_loop()) && e <= _start) || e < _start) {
- return -1;
+ if (!force) {
+ if (((is_auto_punch() || is_auto_loop()) && e <= _start) || e < _start) {
+ return -1;
+ }
}
if (is_mark()) {
@@ -151,8 +163,14 @@ Location::set_end (nframes64_t e)
int
Location::set (nframes64_t start, nframes64_t end)
{
- int const s = set_start (start);
- int const e = set_end (end);
+ /* check validity */
+ if (((is_auto_punch() || is_auto_loop()) && start >= end) || (!is_mark() && start > end)) {
+ return -1;
+ }
+
+ /* now we know these values are ok, so force-set them */
+ int const s = set_start (start, true);
+ int const e = set_end (end, true);
return (s == 0 && e == 0) ? 0 : -1;
}