summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-07-11 20:26:39 -0400
committerDavid Robillard <d@drobilla.net>2016-07-11 20:26:39 -0400
commit2f745fae447200b666c9f5810796d13a20fdf559 (patch)
tree37f5dde7f63fe36c70cf92a44f4b5835ea95aeac /src/plugin.c
parent05f9e858a5dd4b3a1ba5047aa703e55da70dcfdf (diff)
downloadlilv-2f745fae447200b666c9f5810796d13a20fdf559.tar.gz
lilv-2f745fae447200b666c9f5810796d13a20fdf559.tar.bz2
lilv-2f745fae447200b666c9f5810796d13a20fdf559.zip
Fully reset plugin struct when plugin is reloaded
This fixes a bug where, for example, after re-loading a plugin from a different bundle, the LilvPlugin would still report the old bundle. Also never replace a newer version with an older version when a bundle is loaded. Ignores the entire bundle if an older plugin than one loaded is found. This is tricky because the unit of loading/unloading is a bundle, and the unit of versioning is a plugin, but since having data from an old bundle still loaded seems like a bad idea, this seems like the most correct behaviour.
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 837fd62..58cee88 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2014 David Robillard <http://drobilla.net>
+ Copyright 2007-2016 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -32,14 +32,9 @@
#define NS_DOAP (const uint8_t*)"http://usefulinc.com/ns/doap#"
#define NS_FOAF (const uint8_t*)"http://xmlns.com/foaf/0.1/"
-/** Ownership of `uri` is taken */
-LilvPlugin*
-lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri)
+static void
+lilv_plugin_init(LilvPlugin* plugin, LilvNode* bundle_uri)
{
- assert(bundle_uri);
- LilvPlugin* plugin = (LilvPlugin*)malloc(sizeof(LilvPlugin));
- plugin->world = world;
- plugin->plugin_uri = uri;
plugin->bundle_uri = bundle_uri;
plugin->binary_uri = NULL;
#ifdef LILV_DYN_MANIFEST
@@ -52,10 +47,30 @@ lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri)
plugin->loaded = false;
plugin->parse_errors = false;
plugin->replaced = false;
+}
+/** Ownership of `uri` and `bundle` is taken */
+LilvPlugin*
+lilv_plugin_new(LilvWorld* world, LilvNode* uri, LilvNode* bundle_uri)
+{
+ LilvPlugin* plugin = (LilvPlugin*)malloc(sizeof(LilvPlugin));
+
+ plugin->world = world;
+ plugin->plugin_uri = uri;
+
+ lilv_plugin_init(plugin, bundle_uri);
return plugin;
}
+void
+lilv_plugin_clear(LilvPlugin* plugin, LilvNode* bundle_uri)
+{
+ lilv_node_free(plugin->bundle_uri);
+ lilv_node_free(plugin->binary_uri);
+ lilv_nodes_free(plugin->data_uris);
+ lilv_plugin_init(plugin, bundle_uri);
+}
+
static void
lilv_plugin_free_ports(LilvPlugin* p)
{