diff options
author | Carl Hetherington <carl@carlh.net> | 2010-08-20 23:58:49 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-08-20 23:58:49 +0000 |
commit | 067c4458a0ade1ae95f031c98a0ab7b3a349a74f (patch) | |
tree | 916369f82282c8881b67ee3b0d4235ea50ae8c0f /libs/evoral | |
parent | cdb3ade9ffb853c4c43f2d5d54f7d06bb2685480 (diff) |
Don't write undo records for automation that moves with regions when nothing changes about the automation.
git-svn-id: svn://localhost/ardour2/branches/3.0@7665 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/evoral')
-rw-r--r-- | libs/evoral/evoral/ControlList.hpp | 2 | ||||
-rw-r--r-- | libs/evoral/src/ControlList.cpp | 25 |
2 files changed, 21 insertions, 6 deletions
diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index 9d3ba09ef1..f5aef8127d 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -123,7 +123,7 @@ public: void erase_range (double start, double end); void erase (iterator); void erase (iterator, iterator); - void move_ranges (std::list< RangeMove<double> > const &); + bool move_ranges (std::list< RangeMove<double> > const &); void modify (iterator, double, double); boost::shared_ptr<ControlList> cut (double, double); diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index b49b294288..72af04a2d1 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -510,7 +510,9 @@ ControlList::erase_range_internal (double start, double endt, EventList & events cp.when = endt; e = upper_bound (events.begin(), events.end(), &cp, time_comparator); events.erase (s, e); - erased = true; + if (s != e) { + erased = true; + } } return erased; @@ -1354,8 +1356,10 @@ ControlList::paste (ControlList& alist, double pos, float /*times*/) return true; } -/** Move automation around according to a list of region movements */ -void +/** Move automation around according to a list of region movements. + * @param return true if anything was changed, otherwise false (ie nothing needed changing) + */ +bool ControlList::move_ranges (const list< RangeMove<double> >& movements) { typedef list< RangeMove<double> > RangeMoveList; @@ -1367,11 +1371,21 @@ ControlList::move_ranges (const list< RangeMove<double> >& movements) EventList old_events = _events; /* clear the source and destination ranges in the new list */ + bool things_erased = false; for (RangeMoveList::const_iterator i = movements.begin (); i != movements.end (); ++i) { - erase_range_internal (i->from, i->from + i->length, _events); - erase_range_internal (i->to, i->to + i->length, _events); + if (erase_range_internal (i->from, i->from + i->length, _events)) { + things_erased = true; + } + + if (erase_range_internal (i->to, i->to + i->length, _events)) { + things_erased = true; + } + } + /* if nothing was erased, there is nothing to do */ + if (!things_erased) { + return false; } /* copy the events into the new list */ @@ -1399,6 +1413,7 @@ ControlList::move_ranges (const list< RangeMove<double> >& movements) } maybe_signal_changed (); + return true; } void |