From 63b627554cdc10c9903d20ba8a9120414407dfd0 Mon Sep 17 00:00:00 2001 From: Hanspeter Portner Date: Sat, 16 Jul 2022 13:22:52 +0200 Subject: [PATCH] put state:restore into wrap --- lv2lint/lv2lint.h | 1 + meson_options.txt | 2 +- src/lv2lint.c | 21 +++++++++++++++++---- src/lv2lint_plugin.c | 21 +++++++++++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/lv2lint/lv2lint.h b/lv2lint/lv2lint.h index b7591c4..db84731 100644 --- a/lv2lint/lv2lint.h +++ b/lv2lint/lv2lint.h @@ -644,6 +644,7 @@ struct _app_t { int ui_cleanup; int work; int work_response; + int state_restore; } status; varchunk_t *to_worker; varchunk_t *from_worker; diff --git a/meson_options.txt b/meson_options.txt index 82eea39..1a80b49 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,4 +4,4 @@ option('online-tests', type : 'feature', value : 'disabled') option('elf-tests', type : 'feature', value : 'disabled') option('x11-tests', type : 'feature', value : 'disabled') -option('version', type : 'string', value : '0.1.41') +option('version', type : 'string', value : '0.1.43') diff --git a/src/lv2lint.c b/src/lv2lint.c index 8830070..928fd07 100644 --- a/src/lv2lint.c +++ b/src/lv2lint.c @@ -1653,6 +1653,22 @@ _wrap_instantiate(app_t *app, void *data) return 0; } +static int +_wrap_restore(app_t *app, void *data) +{ + LilvState *state = data; + + if(!app->instance) + { + return 1; + } + + lilv_state_restore(state, app->instance, _state_set_value, app, + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE, NULL); //FIXME features + + return 0; +} + static int _wrap_activate(app_t *app, void *data __attribute__((unused))) { @@ -2334,10 +2350,7 @@ main(int argc, char **argv) LilvState *state = lilv_state_new_from_world(app.world, app.map, pset); if(state) { - //FIXME wrap or trace - lilv_state_restore(state, app.instance, _state_set_value, &app, - LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE, NULL); //FIXME features - + app.status.state_restore = lv2lint_wrap(&app, _wrap_restore, state); lilv_state_free(state); } diff --git a/src/lv2lint_plugin.c b/src/lv2lint_plugin.c index a6150a9..617bebe 100644 --- a/src/lv2lint_plugin.c +++ b/src/lv2lint_plugin.c @@ -249,6 +249,26 @@ _test_work_response(app_t *app) return ret; } +static const ret_t * +_test_state_restore(app_t *app) +{ + static const ret_t ret_crash = { + .lnt = LINT_FAIL, + .msg = "crashed", + .uri = LV2_STATE__State, + .dsc = "Well - fix your plugin." + }; + + const ret_t *ret = NULL; + + if(app->status.state_restore) + { + ret = &ret_crash; + } + + return ret; +} + static const ret_t * _test_activate(app_t *app) { @@ -1855,6 +1875,7 @@ static const test_t tests [] = { {"Plugin Run", _test_run}, {"Plugin Work", _test_work}, {"Plugin Work Response", _test_work_response}, + {"Plugin State Restore", _test_state_restore}, {"Plugin Activate", _test_activate}, {"Plugin Deactivate", _test_deactivate}, #ifdef ENABLE_PTRACE_TESTS -- 2.38.5