Ask LuaProc to drop references

This fixes a circular shared_ptr<> reference that prevents
plugin destruction.

LuaProc may hold references to Route that contains the plugin
or the PluginInsert of the LuaPlugin. These are only dropped
when the interpreter collects garbage.

Previously this happened in the d'tor or LuaProc, but while the
Plugin has a reference to the Insert, the Insert is not deleted
and the d'tor is never called.
This commit is contained in:
Robin Gareus 2020-08-05 22:39:06 +02:00
parent c2618903ae
commit 6742a0961c
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 22 additions and 1 deletions

View File

@ -78,6 +78,8 @@ public:
PluginOutputConfiguration possible_output () const { return _output_configs; }
void drop_references ();
std::set<Evoral::Parameter> automatable() const;
void activate () { }

View File

@ -106,6 +106,8 @@ public:
activate ();
}
virtual void drop_references () {}
virtual std::set<Evoral::Parameter> automatable () const = 0;
virtual std::string describe_parameter (Evoral::Parameter) = 0;
virtual std::string state_node_name () const = 0;

View File

@ -61,6 +61,8 @@ public:
PluginInsert (Session&, boost::shared_ptr<Plugin> = boost::shared_ptr<Plugin>());
~PluginInsert ();
void drop_references ();
static const std::string port_automation_node_name;
int set_state(const XMLNode&, int version);

View File

@ -130,7 +130,7 @@ LuaProc::~LuaProc () {
_stats_max[1] * (float)_stats_cnt / _stats_avg[1]);
}
#endif
lua.do_command ("collectgarbage();");
lua.collect_garbage ();
delete (_lua_dsp);
delete (_lua_latency);
delete [] _control_data;
@ -182,6 +182,12 @@ LuaProc::init ()
lua.do_command ("function ardour () end");
}
void
LuaProc::drop_references ()
{
lua.collect_garbage ();
}
boost::weak_ptr<Route>
LuaProc::route () const
{

View File

@ -110,6 +110,15 @@ PluginInsert::~PluginInsert ()
}
}
void
PluginInsert::drop_references ()
{
for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
(*i)->drop_references ();
}
Processor::drop_references ();
}
void
PluginInsert::set_strict_io (bool b)
{