From f02610b47ce8971e0184e4a217279395e24f1234 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 31 Oct 2014 19:41:58 +0100 Subject: [PATCH] LV2 patch amends: * fix Label (user readable key) * check if patch range is a file Path * free some lilv-nodes (plug small mem leak) --- libs/ardour/lv2_plugin.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index b32c4db087..382f46b445 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -557,17 +557,24 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate) * Note: the first Atom-port (in every direction) that supports patch:Message will be used */ LilvNode* rdfs_label = lilv_new_uri(_world.world, LILV_NS_RDFS "label"); + LilvNode* rdfs_range = lilv_new_uri(_world.world, LILV_NS_RDFS "range"); LilvNodes* properties = lilv_world_find_nodes (_world.world, lilv_plugin_get_uri(plugin), _world.patch_writable, NULL); LILV_FOREACH(nodes, p, properties) { const LilvNode* property = lilv_nodes_get(properties, p); LilvNode* label = lilv_nodes_get_first (lilv_world_find_nodes (_world.world, property, rdfs_label, NULL)); + LilvNode* range = lilv_nodes_get_first (lilv_world_find_nodes (_world.world, property, rdfs_range, NULL)); + if (!range || _uri_map.uri_to_id(lilv_node_as_uri(range)) != LV2Plugin::urids.atom_Path) { + continue; + } _patch_value_uri = (char**) realloc (_patch_value_uri, (_patch_count + 1) * sizeof(char**)); _patch_value_key = (char**) realloc (_patch_value_key, (_patch_count + 1) * sizeof(char**)); _patch_value_uri[_patch_count] = strdup(lilv_node_as_uri(property)); - _patch_value_key[_patch_count] = strdup(lilv_node_as_string(property)); + _patch_value_key[_patch_count] = strdup(lilv_node_as_string(label ? label : property)); ++_patch_count; } + lilv_node_free(rdfs_label); + lilv_node_free(rdfs_range); lilv_nodes_free(properties); _patch_value_cur = (char(*)[PATH_MAX]) calloc(_patch_count, sizeof(char[PATH_MAX])); _patch_value_set = (char(*)[PATH_MAX]) calloc(_patch_count, sizeof(char[PATH_MAX])); -- 2.30.2