summaryrefslogtreecommitdiff
path: root/libs/ardour/plugin.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-01-20 00:33:44 +0100
committerRobin Gareus <robin@gareus.org>2017-01-20 00:50:14 +0100
commitb084036c87b57c61eb80a6a4d345b8bf9b0c4857 (patch)
tree9115aa1460f23d55267e0b2dde0800bb576f4774 /libs/ardour/plugin.cc
parent761747760921b5c6b3f4899ca1c40e9aa27bc4a0 (diff)
Fix oddities when replacing VST-presets.
VST used the count of available of presets as URI: - add 2 presets (1,2) - remove first, add another one -> two presets with same URI (2,2) PluginInfo::get_presets() simply lists all (name only) in a vector. Plugin::find_presets() uses the URI in a map (unique by URI). ..various ensuing bugs: eg. Plugin::remove_preset() looked up by name, but didn't check for NULL.
Diffstat (limited to 'libs/ardour/plugin.cc')
-rw-r--r--libs/ardour/plugin.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc
index d21ecfe632..35495488dd 100644
--- a/libs/ardour/plugin.cc
+++ b/libs/ardour/plugin.cc
@@ -102,7 +102,6 @@ Plugin::Plugin (AudioEngine& e, Session& s)
, _parameter_changed_since_last_preset (false)
{
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
- PresetsChanged.connect_same_thread (_preset_connection, boost::bind (&Plugin::update_presets, this, _1 ,_2));
}
Plugin::Plugin (const Plugin& other)
@@ -117,7 +116,6 @@ Plugin::Plugin (const Plugin& other)
, _parameter_changed_since_last_preset (false)
{
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
- PresetsChanged.connect_same_thread (_preset_connection, boost::bind (&Plugin::update_presets, this, _1 ,_2));
}
Plugin::~Plugin ()
@@ -128,18 +126,23 @@ void
Plugin::remove_preset (string name)
{
Plugin::PresetRecord const * p = preset_by_label (name);
+ if (!p) {
+ PBD::error << _("Trying to remove nonexistent preset.") << endmsg;
+ return;
+ }
if (!p->user) {
PBD::error << _("Cannot remove plugin factory preset.") << endmsg;
return;
}
do_remove_preset (name);
- _presets.erase (preset_by_label (name)->uri);
+ _presets.erase (p->uri);
_last_preset.uri = "";
_parameter_changed_since_last_preset = false;
- PresetRemoved (); /* EMIT SIGNAL */
+ _have_presets = false;
PresetsChanged (unique_id(), this); /* EMIT SIGNAL */
+ PresetRemoved (); /* EMIT SIGNAL */
}
/** @return PresetRecord with empty URI on failure */
@@ -155,8 +158,9 @@ Plugin::save_preset (string name)
if (!uri.empty()) {
_presets.insert (make_pair (uri, PresetRecord (uri, name)));
- PresetAdded (); /* EMIT SIGNAL */
+ _have_presets = false;
PresetsChanged (unique_id(), this); /* EMIT SIGNAL */
+ PresetAdded (); /* EMIT SIGNAL */
}
return PresetRecord (uri, name);
@@ -393,18 +397,6 @@ Plugin::resolve_midi ()
_have_pending_stop_events = true;
}
-void
-Plugin::update_presets (std::string src_unique_id, Plugin* src )
-{
- if (src == this || unique_id() != src_unique_id) {
- return;
- }
- _have_presets = false;
- // TODO check if a preset was added/removed and emit the proper signal
- // so far no subscriber distinguishes between PresetAdded and PresetRemoved
- PresetAdded();
-}
-
vector<Plugin::PresetRecord>
Plugin::get_presets ()
{