diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/state.c | 5 | ||||
-rw-r--r-- | test/test.lv2/test.c | 11 |
3 files changed, 18 insertions, 1 deletions
@@ -6,8 +6,9 @@ lilv (0.24.5) unstable; * Fix issues with loading state with saved files from the model * Add option to override LV2_PATH in applications * Fix unit tests on Windows + * Refuse to store duplicate properties when saving plugin state - -- David Robillard <d@drobilla.net> Mon, 15 Apr 2019 23:04:06 +0200 + -- David Robillard <d@drobilla.net> Fri, 21 Jun 2019 21:00:52 +0200 lilv (0.24.4) stable; diff --git a/src/state.c b/src/state.c index e5c789b..9b44c42 100644 --- a/src/state.c +++ b/src/state.c @@ -192,6 +192,11 @@ store_callback(LV2_State_Handle handle, uint32_t flags) { LilvState* const state = (LilvState*)handle; + + if (find_property((const LilvState*)handle, key)) { + return LV2_STATE_ERR_UNKNOWN; // TODO: Add status for duplicate keys + } + append_property(state, &state->props, key, value, size, type, flags); return LV2_STATE_SUCCESS; } diff --git a/test/test.lv2/test.c b/test/test.lv2/test.c index f15b4dd..bf0f87b 100644 --- a/test/test.lv2/test.c +++ b/test/test.lv2/test.c @@ -202,6 +202,17 @@ save(LV2_Handle instance, map_uri(plugin, LV2_ATOM__URID), LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); + // Try to store second value for the same property (should fail) + const uint32_t urid2 = map_uri(plugin, "http://example.org/urivalue2"); + if (!store(callback_data, + map_uri(plugin, "http://example.org/uri"), + &urid2, + sizeof(uint32_t), + map_uri(plugin, LV2_ATOM__URID), + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE)) { + return LV2_STATE_ERR_UNKNOWN; + } + store(callback_data, map_uri(plugin, "http://example.org/num-runs"), &plugin->num_runs, |