diff options
author | David Robillard <d@drobilla.net> | 2008-05-03 23:47:32 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-05-03 23:47:32 +0000 |
commit | 2534a5a90aa3f07af7762da946ca5567e295941a (patch) | |
tree | befabc581e52ba6f2a1af98d6261f2b3fbe441b3 | |
parent | 3f69656ed2a8dee9f5a67041daa8b27e2cd13895 (diff) | |
download | lilv-2534a5a90aa3f07af7762da946ca5567e295941a.tar.gz lilv-2534a5a90aa3f07af7762da946ca5567e295941a.tar.bz2 lilv-2534a5a90aa3f07af7762da946ca5567e295941a.zip |
Handle plugins with missing binaries more gracefully.
git-svn-id: http://svn.drobilla.net/lad/slv2@1197 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/plugin.c | 2 | ||||
-rw-r--r-- | src/world.c | 42 |
2 files changed, 24 insertions, 20 deletions
diff --git a/src/plugin.c b/src/plugin.c index 1479bc6..ebd51b2 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -38,6 +38,8 @@ SLV2Plugin slv2_plugin_new(SLV2World world, SLV2Value uri, librdf_uri* bundle_uri, librdf_uri* binary_uri) { + assert(bundle_uri); + assert(binary_uri); struct _SLV2Plugin* plugin = malloc(sizeof(struct _SLV2Plugin)); plugin->world = world; plugin->plugin_uri = uri; diff --git a/src/world.c b/src/world.c index 1d2f339..2efcc40 100644 --- a/src/world.c +++ b/src/world.c @@ -528,33 +528,35 @@ slv2_world_load_all(SLV2World world) librdf_node* bundle_node = librdf_query_results_get_binding_value(results, 2); librdf_uri* bundle_uri = librdf_node_get_uri(bundle_node); librdf_node* binary_node = librdf_query_results_get_binding_value(results, 3); - librdf_uri* binary_uri = binary_node ? librdf_node_get_uri(binary_node) : NULL; assert(plugin_uri); assert(data_uri); - // printf("PLUGIN: %s\n", librdf_uri_as_string(plugin_uri)); - - SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri); - - SLV2Plugin plugin = slv2_plugins_get_by_uri(world->plugins, uri); - - // Create a new SLV2Plugin - if (!plugin) { - plugin = slv2_plugin_new(world, uri, bundle_uri, binary_uri); - raptor_sequence_push(world->plugins, plugin); - // FIXME: Slow! ORDER BY broken in certain versions of redland? - raptor_sequence_sort(world->plugins, slv2_plugin_compare_by_uri); + if (binary_node) { + librdf_uri* binary_uri = librdf_node_get_uri(binary_node); + SLV2Value uri = slv2_value_new_librdf_uri(world, plugin_uri); + SLV2Plugin plugin = slv2_plugins_get_by_uri(world->plugins, uri); + + // Create a new SLV2Plugin + if (!plugin) { + plugin = slv2_plugin_new(world, uri, bundle_uri, binary_uri); + raptor_sequence_push(world->plugins, plugin); + // FIXME: Slow! ORDER BY broken in certain versions of redland? + raptor_sequence_sort(world->plugins, slv2_plugin_compare_by_uri); + } else { + slv2_value_free(uri); + } + + plugin->world = world; + + // FIXME: check for duplicates + raptor_sequence_push(plugin->data_uris, + slv2_value_new_librdf_uri(plugin->world, data_uri)); } else { - slv2_value_free(uri); + fprintf(stderr, "Warning: plugin %s has no binary; ignored.\n", + librdf_uri_as_string(plugin_uri)); } - plugin->world = world; - - // FIXME: check for duplicates - raptor_sequence_push(plugin->data_uris, - slv2_value_new_librdf_uri(plugin->world, data_uri)); - librdf_free_node(plugin_node); librdf_free_node(data_node); librdf_free_node(bundle_node); |