summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-10-21 02:10:24 +0000
committerDavid Robillard <d@drobilla.net>2009-10-21 02:10:24 +0000
commit20714a82da8b6c808be5f17d7add9e164ab154e3 (patch)
tree157c5f1b5c99be6c32064da059e5b9b6283ad50f
parenta0108c19c4704316a02c85676af349acdda29d72 (diff)
downloadingen-20714a82da8b6c808be5f17d7add9e164ab154e3.tar.gz
ingen-20714a82da8b6c808be5f17d7add9e164ab154e3.tar.bz2
ingen-20714a82da8b6c808be5f17d7add9e164ab154e3.zip
Fix crash when plugins fail to instantiate.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2199 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/engine/LV2Node.cpp5
-rw-r--r--src/engine/events/CreateNode.cpp14
-rw-r--r--src/engine/events/CreateNode.hpp2
3 files changed, 14 insertions, 7 deletions
diff --git a/src/engine/LV2Node.cpp b/src/engine/LV2Node.cpp
index 92f32b3c..df2ccbb2 100644
--- a/src/engine/LV2Node.cpp
+++ b/src/engine/LV2Node.cpp
@@ -60,8 +60,9 @@ LV2Node::LV2Node(LV2Plugin* plugin,
LV2Node::~LV2Node()
{
- for (uint32_t i=0; i < _polyphony; ++i)
- slv2_instance_free((*_instances)[i]);
+ if (_instances)
+ for (uint32_t i=0; i < _polyphony; ++i)
+ slv2_instance_free((*_instances)[i]);
delete _instances;
}
diff --git a/src/engine/events/CreateNode.cpp b/src/engine/events/CreateNode.cpp
index 48d25348..966f96c1 100644
--- a/src/engine/events/CreateNode.cpp
+++ b/src/engine/events/CreateNode.cpp
@@ -54,6 +54,7 @@ CreateNode::CreateNode(
, _plugin_uri(plugin_uri)
, _polyphonic(polyphonic)
, _patch(NULL)
+ , _plugin(NULL)
, _node(NULL)
, _compiled_patch(NULL)
, _node_already_exists(false)
@@ -83,16 +84,16 @@ CreateNode::pre_process()
_patch = _engine.engine_store()->find_patch(_path.parent());
- PluginImpl* const plugin = (_plugin_label == "")
+ _plugin = (_plugin_label == "")
? _engine.node_factory()->plugin(_plugin_uri.str())
: _engine.node_factory()->plugin(_plugin_type, _plugin_lib, _plugin_label);
- if (_patch && plugin) {
+ if (_patch && _plugin) {
- _node = plugin->instantiate(_path.name(), _polyphonic, _patch, _engine);
- _node->properties().insert(_properties.begin(), _properties.end());
+ _node = _plugin->instantiate(_path.name(), _polyphonic, _patch, _engine);
if (_node != NULL) {
+ _node->properties().insert(_properties.begin(), _properties.end());
_node->activate();
// This can be done here because the audio thread doesn't touch the
@@ -134,10 +135,13 @@ CreateNode::post_process()
} else if (_patch == NULL) {
msg = "Could not find patch '" + _path.parent().str() +"' to add node.";
_responder->respond_error(msg);
- } else if (_node == NULL) {
+ } else if (_plugin == NULL) {
msg = "Unable to load node ";
msg += _path.str() + " (you're missing the plugin " + _plugin_uri.str() + ")";
_responder->respond_error(msg);
+ } else if (_node == NULL) {
+ msg = "Failed to instantiate plugin " + _plugin_uri.str();
+ _responder->respond_error(msg);
} else {
_responder->respond_ok();
_engine.broadcaster()->send_object(_node, true); // yes, send ports
diff --git a/src/engine/events/CreateNode.hpp b/src/engine/events/CreateNode.hpp
index e44008e4..8f2379b0 100644
--- a/src/engine/events/CreateNode.hpp
+++ b/src/engine/events/CreateNode.hpp
@@ -25,6 +25,7 @@
namespace Ingen {
class PatchImpl;
+class PluginImpl;
class NodeImpl;
class CompiledPatch;
@@ -59,6 +60,7 @@ private:
std::string _plugin_label;
bool _polyphonic;
PatchImpl* _patch;
+ PluginImpl* _plugin;
NodeImpl* _node;
CompiledPatch* _compiled_patch; ///< Patch's new process order
bool _node_already_exists;