summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-31 02:00:16 +0000
committerDavid Robillard <d@drobilla.net>2011-05-31 02:00:16 +0000
commitd367b210f41088877f094c2e9ccca50ec4851929 (patch)
treeb2bb5c75c4194026a35eb7590e5a1099f5bd5161
parenta206c5c4a969ca6bd4984ec50a8ece40c8ef8e53 (diff)
Create and destroy (non-external) LV2 plugin UIs as window is shown/hidden.
Fixes ticket #4067 (not to mention avoids having every UI that has ever been shown loaded in memory until exit time...) git-svn-id: svn://localhost/ardour2/branches/3.0@9638 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/lv2_plugin_ui.cc39
-rw-r--r--gtk2_ardour/lv2_plugin_ui.h1
2 files changed, 29 insertions, 11 deletions
diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc
index 9303702fa2..330020ba93 100644
--- a/gtk2_ardour/lv2_plugin_ui.cc
+++ b/gtk2_ardour/lv2_plugin_ui.cc
@@ -118,8 +118,7 @@ LV2PluginUI::stop_updating(GdkEventAny*)
{
//cout << "stop_updating" << endl;
- if ( //!_external_ui_ptr &&
- !_output_ports.empty()) {
+ if (!_output_ports.empty()) {
_screen_update_connection.disconnect();
}
return false;
@@ -146,13 +145,11 @@ LV2PluginUI::LV2PluginUI(boost::shared_ptr<PluginInsert> pi,
boost::shared_ptr<LV2Plugin> lv2p)
: PlugUIBase(pi)
, _lv2(lv2p)
+ , _gui_widget(NULL)
, _values(NULL)
, _external_ui_ptr(NULL)
, _inst(NULL)
{
- if (!_lv2->is_external_ui()) {
- lv2ui_instantiate("gtk2gui");
- }
}
void
@@ -264,15 +261,16 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
}
}
-LV2PluginUI::~LV2PluginUI ()
+void
+LV2PluginUI::lv2ui_free()
{
- //cout << "LV2PluginUI destructor called" << endl;
-
- if (_values) {
- delete[] _values;
+ if (_lv2->is_external_ui() || !_gui_widget) {
+ return;
}
- /* Close and delete GUI. */
+ stop_updating(NULL);
+ remove(*_gui_widget);
+
#ifdef HAVE_SUIL
suil_instance_free((SuilInstance*)_inst);
#else
@@ -285,6 +283,21 @@ LV2PluginUI::~LV2PluginUI ()
}
#endif
+ _inst = NULL;
+ _gui_widget = NULL;
+}
+
+LV2PluginUI::~LV2PluginUI ()
+{
+ //cout << "LV2PluginUI destructor called" << endl;
+
+ if (_values) {
+ delete[] _values;
+ }
+
+ /* Close and delete GUI. */
+ lv2ui_free();
+
_screen_update_connection.disconnect();
if (_lv2->is_external_ui()) {
@@ -362,6 +375,8 @@ LV2PluginUI::on_window_show(const std::string& title)
_screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
(sigc::mem_fun(*this, &LV2PluginUI::output_update));
return false;
+ } else {
+ lv2ui_instantiate("gtk2gui");
}
return true;
@@ -377,5 +392,7 @@ LV2PluginUI::on_window_hide()
//slv2_ui_instance_get_descriptor(_inst)->cleanup(_inst);
//_external_ui_ptr = NULL;
//_screen_update_connection.disconnect();
+ } else {
+ lv2ui_free();
}
}
diff --git a/gtk2_ardour/lv2_plugin_ui.h b/gtk2_ardour/lv2_plugin_ui.h
index 7fb311c81f..a6606c64dd 100644
--- a/gtk2_ardour/lv2_plugin_ui.h
+++ b/gtk2_ardour/lv2_plugin_ui.h
@@ -87,6 +87,7 @@ class LV2PluginUI : public PlugUIBase, public Gtk::VBox
const void* buffer);
void lv2ui_instantiate(const std::string& title);
+ void lv2ui_free();
void parameter_update(uint32_t, float);
bool configure_handler (GdkEventConfigure*);