From de359e5e23b77bae47b71ff0aadfb22ead4119b2 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 6 Mar 2010 20:56:25 +0000 Subject: [PATCH] remove global LV2 external GUI list, always call LV2 UI cleanup method when appropriate; still need to verify that all plugin UIs are destroyed at session close git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@6741 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/lv2_plugin_ui.cc | 46 +++++++++++++----------------------- gtk2_ardour/main.cc | 8 +------ 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc index 7fb2c87b05..c4f010a165 100644 --- a/gtk2_ardour/lv2_plugin_ui.cc +++ b/gtk2_ardour/lv2_plugin_ui.cc @@ -28,22 +28,6 @@ using namespace Gtk; using namespace ARDOUR; using namespace PBD; -std::vector g_external_uis; - -void close_external_ui_windows() -{ - struct lv2_external_ui* external_ui_ptr; - - //cout << "close_external_ui_windows" << endl; - - while (!g_external_uis.empty()) { - //cout << "pop" << endl; - external_ui_ptr = g_external_uis.back(); - LV2_EXTERNAL_UI_HIDE(external_ui_ptr); - g_external_uis.pop_back(); - } -} - void LV2PluginUI::lv2_ui_write(LV2UI_Controller controller, uint32_t port_index, @@ -61,19 +45,8 @@ LV2PluginUI::lv2_ui_write(LV2UI_Controller controller, void LV2PluginUI::on_external_ui_closed(LV2UI_Controller controller) { - //cout << "on_external_ui_closed" << endl; - LV2PluginUI* me = (LV2PluginUI*)controller; me->_screen_update_connection.disconnect(); - //me->insert->set_gui(0); - - for (vector::iterator it = g_external_uis.begin() ; it < g_external_uis.end(); it++) { - if (*it == me->_external_ui_ptr) { - g_external_uis.erase(it); - } - } - - //slv2_ui_instance_get_descriptor(me->_inst)->cleanup(me->_inst); me->_external_ui_ptr = NULL; } @@ -214,7 +187,6 @@ LV2PluginUI::lv2ui_instantiate(const Glib::ustring& title) pack_start(*_gui_widget, true, true); } else { _external_ui_ptr = (struct lv2_external_ui *)slv2_ui_instance_get_widget(_inst); - g_external_uis.push_back(_external_ui_ptr); } } @@ -240,7 +212,23 @@ LV2PluginUI::~LV2PluginUI () if (_values) { delete[] _values; } - // plugin destructor destroys the GTK GUI + + + const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(_inst); + LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(_inst); + + /*Call cleanup to tell the plugin to close its GUI and delete it*/ + + if (ui_desc) { + ui_desc->cleanup(ui_handle); + } + + _screen_update_connection.disconnect(); + + if (_lv2->is_external_ui()) { + /*external UI is no longer valid - on_window_hide() will not try to use it if is NULL*/ + _external_ui_ptr = NULL; + } } int diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 7b5fce1775..dc615d5bc2 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -291,10 +291,6 @@ sigpipe_handler (int sig) } } -#ifdef HAVE_LV2 -void close_external_ui_windows(); -#endif - #ifdef VST_SUPPORT extern int gui_init (int* argc, char** argv[]); @@ -399,9 +395,7 @@ int main (int argc, char* argv[]) ARDOUR::cleanup (); pthread_cancel_all (); -#ifdef HAVE_LV2 - close_external_ui_windows(); -#endif + return 0; } #ifdef VST_SUPPORT