From bde3edf1c8f5075af5913eaea4dc81b199a17138 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 25 Jul 2017 20:15:12 +0200 Subject: Make start_touch() truly idempotent Also don't allow outsiders to call Controllable::set_touching() --- libs/ardour/automation_control.cc | 47 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'libs/ardour/automation_control.cc') diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc index e9bc1aebe0..9b7628a7ad 100644 --- a/libs/ardour/automation_control.cc +++ b/libs/ardour/automation_control.cc @@ -266,42 +266,41 @@ AutomationControl::set_automation_state (AutoState as) } void -AutomationControl::start_touch(double when) +AutomationControl::start_touch (double when) { - if (!_list) { + if (!_list || touching ()) { return; } - if (!touching()) { - if (alist()->automation_state() == Touch) { - /* subtle. aligns the user value with the playback and - * use take actual value (incl masters). - * - * Touch + hold writes inverse curve of master-automation - * using AutomationWatch::timer () - */ - AutomationControl::actually_set_value (get_value (), Controllable::NoGroup); - alist()->start_touch (when); - if (!_desc.toggled) { - AutomationWatch::instance().add_automation_watch (shared_from_this()); - } + if (alist()->automation_state() == Touch) { + /* subtle. aligns the user value with the playback and + * use take actual value (incl masters). + * + * Touch + hold writes inverse curve of master-automation + * using AutomationWatch::timer () + */ + AutomationControl::actually_set_value (get_value (), Controllable::NoGroup); + alist()->start_touch (when); + if (!_desc.toggled) { + AutomationWatch::instance().add_automation_watch (shared_from_this()); } set_touching (true); } } void -AutomationControl::stop_touch(double when) +AutomationControl::stop_touch (double when) { - if (!_list) return; - if (touching()) { - set_touching (false); + if (!_list || !touching ()) { + return; + } - if (alist()->automation_state() == Touch) { - alist()->stop_touch (when); - if (!_desc.toggled) { - AutomationWatch::instance().remove_automation_watch (shared_from_this()); - } + set_touching (false); + + if (alist()->automation_state() == Touch) { + alist()->stop_touch (when); + if (!_desc.toggled) { + AutomationWatch::instance().remove_automation_watch (shared_from_this()); } } } -- cgit v1.2.3