From 8dcc28c9ad91baade9c30a2ec6d59a1f799dc654 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 21 Jun 2017 12:07:12 +0200 Subject: [PATCH] Remove duplicates from ControlList --- libs/evoral/evoral/ControlList.hpp | 1 + libs/evoral/src/ControlList.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) 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::functionwhen == (*i)->when && (*prev)->value == (*i)->value) { + i = _events.erase (i); + } else { + ++prev; + ++i; + } + } +} + void ControlList::start_write_pass (double when) { @@ -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 >& movements) if (!_frozen) { _events.sort (event_time_less_than); + unlocked_remove_duplicates (); unlocked_invalidate_insert_iterator (); } else { _sort_pending = true;