diff options
author | Robin Gareus <robin@gareus.org> | 2017-06-21 12:07:12 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2017-06-21 18:12:31 +0200 |
commit | 8dcc28c9ad91baade9c30a2ec6d59a1f799dc654 (patch) | |
tree | 6b50fb1f3a686adaf77601c38933db4751197383 /libs/evoral | |
parent | 3d15499cdacacbafa32c8fcfb1389e6f0716ce9c (diff) |
Remove duplicates from ControlList
Diffstat (limited to 'libs/evoral')
-rw-r--r-- | libs/evoral/evoral/ControlList.hpp | 1 | ||||
-rw-r--r-- | libs/evoral/src/ControlList.cpp | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index c4051193b8..8df5004b39 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -356,6 +356,7 @@ private: bool did_write_during_pass; bool _in_write_pass; + void unlocked_remove_duplicates (); void unlocked_invalidate_insert_iterator (); void add_guard_point (double when); }; diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index 4ee50a3635..8bb1c125d2 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -314,6 +314,7 @@ ControlList::list_merge (ControlList const& other, boost::function<double(double _events.clear (); _events = nel; + unlocked_remove_duplicates (); unlocked_invalidate_insert_iterator (); mark_dirty (); } @@ -427,6 +428,24 @@ ControlList::unlocked_invalidate_insert_iterator () } void +ControlList::unlocked_remove_duplicates () +{ + if (_events.size() < 2) { + return; + } + iterator i = _events.begin(); + iterator prev = i++; + while (i != _events.end()) { + if ((*prev)->when == (*i)->when && (*prev)->value == (*i)->value) { + i = _events.erase (i); + } else { + ++prev; + ++i; + } + } +} + +void ControlList::start_write_pass (double when) { Glib::Threads::RWLock::WriterLock lm (_lock); @@ -954,6 +973,7 @@ ControlList::modify (iterator iter, double when, double val) if (!_frozen) { _events.sort (event_time_less_than); + unlocked_remove_duplicates (); unlocked_invalidate_insert_iterator (); } else { _sort_pending = true; @@ -1018,6 +1038,7 @@ ControlList::thaw () if (_sort_pending) { _events.sort (event_time_less_than); + unlocked_remove_duplicates (); unlocked_invalidate_insert_iterator (); _sort_pending = false; } @@ -1859,6 +1880,7 @@ ControlList::move_ranges (const list< RangeMove<double> >& movements) if (!_frozen) { _events.sort (event_time_less_than); + unlocked_remove_duplicates (); unlocked_invalidate_insert_iterator (); } else { _sort_pending = true; |