From 8bda2ea54dd6832e30ec78437a0c9344af704db3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 23 Dec 2021 14:51:52 -0700 Subject: [PATCH] triggerbox: when calling ::set_state() do not use worker thread This avoids creating a new Trigger with the correct state, and instead sets the state of the current Trigger. Also change order of ::set_state() so that the othe Trigger properties are set after the region is set. Setting the region may set defaults that are no longer correct. --- libs/ardour/ardour/triggerbox.h | 2 +- libs/ardour/triggerbox.cc | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 6601f25a26..584243dd46 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -178,7 +178,7 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { FollowAction follow_action (uint32_t n) const { assert (n < 2); return n ? _follow_action1 : _follow_action0; } void set_follow_action (FollowAction, uint32_t n); - void set_region (boost::shared_ptr); + void set_region (boost::shared_ptr, bool use_thread = true); void clear_region (); virtual int set_region_in_worker_thread (boost::shared_ptr) = 0; boost::shared_ptr region() const { return _region; } diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 64fcf8472a..1c24df8058 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -246,11 +246,9 @@ Trigger::get_state (void) int Trigger::set_state (const XMLNode& node, int version) { - PropertyChange what_changed; - - what_changed = set_values (node); - - node.get_property (X_("index"), _index); + /* Set region first since set_region_in_worker_thread() will set some + values that may/will need to be overridden by XML + */ PBD::ID rid; @@ -259,9 +257,13 @@ Trigger::set_state (const XMLNode& node, int version) boost::shared_ptr r = RegionFactory::region_by_id (rid); if (r) { - set_region (r); + set_region (r, false); } + set_values (node); + + node.get_property (X_("index"), _index); + return 0; } @@ -291,7 +293,7 @@ Trigger::set_quantization (Temporal::BBT_Offset const & q) } void -Trigger::set_region (boost::shared_ptr r) +Trigger::set_region (boost::shared_ptr r, bool use_thread) { /* Called from (G)UI thread */ @@ -299,9 +301,11 @@ Trigger::set_region (boost::shared_ptr r) /* clear operation, no need to talk to the worker thread */ set_pending ((Trigger*) Trigger::MagicClearPointerValue); request_stop (); - } else { + } else if (use_thread) { /* load data, do analysis in another thread */ TriggerBox::worker->set_region (_box, index(), r); + } else { + set_region_in_worker_thread (r); } }