From 33e8abe6b3a6eedccf3049a8114d41c3f5526473 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Tue, 10 Jan 2012 14:38:58 +0000 Subject: [PATCH] Remove the plugin ui widget before deleting the plugin. this fixes a crash when deleting Invada lv2 plugins after the gui has been instantiated. from a3. git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@11218 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/lv2_plugin_ui.cc | 23 ++++++++++++++++++++--- gtk2_ardour/lv2_plugin_ui.h | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc index 0fbf77d50b..ba06a5a824 100644 --- a/gtk2_ardour/lv2_plugin_ui.cc +++ b/gtk2_ardour/lv2_plugin_ui.cc @@ -231,6 +231,23 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title) _lv2->ParameterChanged.connect(mem_fun(*this, &LV2PluginUI::parameter_changed)); } +void +LV2PluginUI::lv2ui_free() +{ + stop_updating (0); + + if (_gui_widget) { + remove (*_gui_widget); + } + + suil_instance_free((SuilInstance*)_inst); + + _inst = NULL; + _gui_widget = NULL; +} + + + LV2PluginUI::~LV2PluginUI () { //cout << "LV2PluginUI destructor called" << endl; @@ -239,9 +256,9 @@ LV2PluginUI::~LV2PluginUI () delete[] _values; } - suil_instance_free(_inst); - _inst = NULL; - + /* Close and delete GUI. */ + lv2ui_free(); + _screen_update_connection.disconnect(); if (_lv2->is_external_ui()) { diff --git a/gtk2_ardour/lv2_plugin_ui.h b/gtk2_ardour/lv2_plugin_ui.h index 06455c2da1..665195437d 100644 --- a/gtk2_ardour/lv2_plugin_ui.h +++ b/gtk2_ardour/lv2_plugin_ui.h @@ -81,6 +81,7 @@ class LV2PluginUI : public PlugUIBase, public Gtk::VBox const void* buffer); void lv2ui_instantiate(const std::string& title); + void lv2ui_free(); void parameter_changed(uint32_t, float); void parameter_update(uint32_t, float);