From: Carl Hetherington Date: Fri, 20 Aug 2010 23:58:49 +0000 (+0000) Subject: Don't write undo records for automation that moves with regions when nothing changes... X-Git-Tag: 3.0-alpha5~1598 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=067c4458a0ade1ae95f031c98a0ab7b3a349a74f;p=ardour.git 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 --- diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index 064049049b..aaeb3c9270 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -466,9 +466,11 @@ Diskstream::playlist_ranges_moved (list< Evoral::RangeMove > const & for (uint32_t i = 0; i < p->npanners (); ++i) { boost::shared_ptr pan_alist = p->streampanner(i).pan_control()->alist(); XMLNode & before = pan_alist->get_state (); - pan_alist->move_ranges (movements); - _session.add_command (new MementoCommand ( - *pan_alist.get(), &before, &pan_alist->get_state ())); + bool const things_moved = pan_alist->move_ranges (movements); + if (things_moved) { + _session.add_command (new MementoCommand ( + *pan_alist.get(), &before, &pan_alist->get_state ())); + } } } @@ -485,25 +487,23 @@ Diskstream::move_processor_automation (boost::weak_ptr p, list< Evora } list< Evoral::RangeMove > movements; - for (list< Evoral::RangeMove >::const_iterator i = movements_frames.begin(); - i != movements_frames.end(); ++i) { + for (list< Evoral::RangeMove >::const_iterator i = movements_frames.begin(); i != movements_frames.end(); ++i) { movements.push_back(Evoral::RangeMove(i->from, i->length, i->to)); } set const a = processor->what_can_be_automated (); - cout << "move processor auto for " << processor->name() << "\n"; - for (set::iterator i = a.begin (); i != a.end (); ++i) { - cout << "moving " << *i << "\n"; boost::shared_ptr al = processor->automation_control(*i)->alist(); XMLNode & before = al->get_state (); - al->move_ranges (movements); - _session.add_command ( - new MementoCommand ( - *al.get(), &before, &al->get_state () - ) - ); + bool const things_moved = al->move_ranges (movements); + if (things_moved) { + _session.add_command ( + new MementoCommand ( + *al.get(), &before, &al->get_state () + ) + ); + } } } 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 > const &); + bool move_ranges (std::list< RangeMove > const &); void modify (iterator, double, double); boost::shared_ptr 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 >& movements) { typedef list< RangeMove > RangeMoveList; @@ -1367,11 +1371,21 @@ ControlList::move_ranges (const list< RangeMove >& 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 >& movements) } maybe_signal_changed (); + return true; } void