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.
This commit is contained in:
Paul Davis 2021-12-23 14:51:52 -07:00
parent 541b91d293
commit 8bda2ea54d
2 changed files with 13 additions and 9 deletions

View file

@ -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<Region>);
void set_region (boost::shared_ptr<Region>, bool use_thread = true);
void clear_region ();
virtual int set_region_in_worker_thread (boost::shared_ptr<Region>) = 0;
boost::shared_ptr<Region> region() const { return _region; }

View file

@ -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<Region> 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<Region> r)
Trigger::set_region (boost::shared_ptr<Region> r, bool use_thread)
{
/* Called from (G)UI thread */
@ -299,9 +301,11 @@ Trigger::set_region (boost::shared_ptr<Region> 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);
}
}