diff options
author | David Robillard <d@drobilla.net> | 2012-07-15 17:35:14 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-07-15 17:35:14 +0000 |
commit | 2fbfd73d888ef89f80f3093cb45da4a94b7748f7 (patch) | |
tree | 4817f3344b383a2143c8436b9ac1e2e8f28a67ac /src | |
parent | f131f6f18dedfdca6c89922a8a1ac7ed6b1c904a (diff) | |
download | lilv-2fbfd73d888ef89f80f3093cb45da4a94b7748f7.tar.gz lilv-2fbfd73d888ef89f80f3093cb45da4a94b7748f7.tar.bz2 lilv-2fbfd73d888ef89f80f3093cb45da4a94b7748f7.zip |
Gracefully handle failure to save plugin state and print error message.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4537 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/state.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/state.c b/src/state.c index 03485b9..d644528 100644 --- a/src/state.c +++ b/src/state.c @@ -306,6 +306,19 @@ absolute_dir(const char* path) return base; } +static const char* +state_strerror(LV2_State_Status st) +{ + switch (st) { + case LV2_STATE_SUCCESS: return "Completed successfully"; + case LV2_STATE_ERR_UNKNOWN: return "Unknown error"; + case LV2_STATE_ERR_BAD_TYPE: return "Unsupported type"; + case LV2_STATE_ERR_BAD_FLAGS: return "Unsupported flags"; + case LV2_STATE_ERR_NO_FEATURE: return "Missing features"; + case LV2_STATE_ERR_NO_PROPERTY: return "Missing property"; + } +} + LILV_API LilvState* lilv_state_new_from_instance(const LilvPlugin* plugin, @@ -365,8 +378,14 @@ lilv_state_new_from_instance(const LilvPlugin* plugin, : NULL; if (iface) { - iface->save(instance->lv2_handle, store_callback, - state, flags, features); + LV2_State_Status st = iface->save( + instance->lv2_handle, store_callback, state, flags, features); + if (st) { + LILV_ERRORF("Error saving plugin state: %s\n", state_strerror(st)); + free(state->props); + state->props = NULL; + state->num_props = 0; + } } qsort(state->props, state->num_props, sizeof(Property), property_cmp); |