From 1a3b82a12e9de48d5b7763a0bbc6a887e1d9f943 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sun, 20 Mar 2022 09:40:20 -0500 Subject: [PATCH] triggerbox: TRIGGER_DIRECT_SET should also set ui_state bugfix: changing the FA state can overwrite the clip's name and color Some params (like gain) can and should take effect immediately by directly setting the properties. TRIGGER_DIRECT_SET does that. But we still, ALSO have to set the ui_state, because when the triggerbox imports ui_state via update_properties() it will overwrite your changes. Said another way: since we use a queued ui_state to set the properties, you ALWAYS have to set and use the ui_state mechanism, even if you want to short-circuit the process for specific properties. --- libs/ardour/triggerbox.cc | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 3e6b3974ca..e10040404a 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -494,6 +494,10 @@ Trigger::set_ ## name (type val) \ { \ if (_ ## name == val) { return; } \ _ ## name = val; \ + ui_state.name = val; \ + unsigned int g = ui_state.generation.load(); \ + do { ui_state.name = val; } while (!ui_state.generation.compare_exchange_strong (g, g+1)); \ + DEBUG_TRACE (DEBUG::Triggers, string_compose ("trigger %1 property& cas-set: %2 gen %3\n", index(), _ ## name.property_name(), ui_state.generation.load())); \ send_property_change (Properties::name); /* EMIT SIGNAL */ \ _box.session().set_dirty (); \ } \ @@ -509,6 +513,10 @@ Trigger::set_ ## name (type const & val) \ { \ if (_ ## name == val) { return; } \ _ ## name = val; \ + ui_state.name = val; \ + unsigned int g = ui_state.generation.load(); \ + do { ui_state.name = val; } while (!ui_state.generation.compare_exchange_strong (g, g+1)); \ + DEBUG_TRACE (DEBUG::Triggers, string_compose ("trigger %1 property& cas-set: %2 gen %3\n", index(), _ ## name.property_name(), ui_state.generation.load())); \ send_property_change (Properties::name); /* EMIT SIGNAL */ \ _box.session().set_dirty (); \ } \ @@ -520,6 +528,7 @@ Trigger::name () const \ TRIGGER_DIRECT_SET_CONST_REF (name, std::string) TRIGGER_DIRECT_SET (color, color_t) +TRIGGER_DIRECT_SET (gain, gain_t) void Trigger::set_ui (void* p) @@ -548,25 +557,6 @@ Trigger::set_allow_patch_changes (bool yn) _box.session().set_dirty(); } -gain_t -Trigger::gain () const -{ - return _gain; -} - - -void -Trigger::set_gain (gain_t g) -{ - if (_gain == g) { - return; - } - - _gain = g; - send_property_change (Properties::gain); - _box.session().set_dirty(); -} - void Trigger::bang () {