LV2 state cleanup, patch from deva. closes #6607
authorRobin Gareus <robin@gareus.org>
Sun, 27 Sep 2015 12:07:04 +0000 (14:07 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 27 Sep 2015 12:07:57 +0000 (14:07 +0200)
set _impl->state on session load in order to detect state changes
properly (no not save duplicate states).

+ some small mem-leaks (free state)

libs/ardour/lv2_plugin.cc

index cd1c190c383b0810fb55a49f66222834d4a5f5f4..1c3db86db552febb1316a5436e24cc11c942f475 100644 (file)
@@ -480,6 +480,7 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate)
        if (state && _has_state_interface) {
                lilv_state_restore(state, _impl->instance, NULL, NULL, 0, NULL);
        }
+       lilv_state_free(state);
 #endif
 
        _sample_rate = rate;
@@ -682,6 +683,7 @@ LV2Plugin::~LV2Plugin ()
        cleanup();
 
        lilv_instance_free(_impl->instance);
+       lilv_state_free(_impl->state);
        lilv_node_free(_impl->name);
        lilv_node_free(_impl->author);
        free(_impl->options);
@@ -1696,6 +1698,8 @@ LV2Plugin::set_state(const XMLNode& node, int version)
                        _world.world, _uri_map.urid_map(), NULL, state_file.c_str());
 
                lilv_state_restore(state, _impl->instance, NULL, NULL, 0, NULL);
+               lilv_state_free(_impl->state);
+               _impl->state = state;
        }
 
        latency_compute_run();