From ce2db42fb605322bc9758e9c19d802261be63ad1 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 13 Mar 2015 16:25:47 +0000 Subject: Check for options interface before getting. Fixes crash with plugins that do not define extension_data(). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5627 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/LV2Block.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/server') diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 64c80764..5ab1dbe1 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -77,8 +77,10 @@ LV2Block::make_instance(URIs& uris, uint32_t voice, bool preparing) { - LilvInstance* inst = lilv_plugin_instantiate( - _lv2_plugin->lilv_plugin(), rate, _features->array()); + LilvWorld* lworld = _lv2_plugin->lv2_info()->lv2_world(); + const LilvPlugin* lplug = _lv2_plugin->lilv_plugin(); + LilvInstance* inst = lilv_plugin_instantiate( + lplug, rate, _features->array()); if (!inst) { parent_graph()->engine().log().error( @@ -87,8 +89,15 @@ LV2Block::make_instance(URIs& uris, return SPtr(); } - const LV2_Options_Interface* options_iface = (const LV2_Options_Interface*) - lilv_instance_get_extension_data(inst, LV2_OPTIONS__interface); + LilvNode* opt_interface = lilv_new_uri(lworld, LV2_OPTIONS__interface); + + const LV2_Options_Interface* options_iface = NULL; + if (lilv_plugin_has_extension_data(lplug, opt_interface)) { + options_iface = (const LV2_Options_Interface*) + lilv_instance_get_extension_data(inst, LV2_OPTIONS__interface); + } + + lilv_node_free(opt_interface); for (uint32_t p = 0; p < num_ports(); ++p) { PortImpl* const port = _ports->at(p); -- cgit v1.2.1