From 3ced8cc6bcae213f8e063c6222ae9e9f3512f90a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 27 Aug 2024 01:09:06 +0200 Subject: [PATCH] RegionFX: fix undo/redo of region state Previously this caused deadlocks (read lock while holding write lock), and also not dropped references of plugins. Ideally undo/redo of FX unrelated region state will not re-instantiate plugins; we can optimize this later. --- libs/ardour/region.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index 9c65b38c18..a90f0bc8cc 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1579,6 +1579,10 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang Glib::Threads::RWLock::WriterLock lm (_fx_lock); bool changed = !_plugins.empty (); + for (auto const& rfx : _plugins) { + rfx->drop_references (); + } + _plugins.clear (); for (auto const& child : node.children ()) { @@ -1596,6 +1600,7 @@ Region::_set_state (const XMLNode& node, int version, PropertyChange& what_chang changed = true; } } + lm.release (); if (changed) { fx_latency_changed (true); fx_tail_changed (true);