diff --git a/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc b/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc index 1ec184fdf3..9890317a43 100644 --- a/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc +++ b/libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc @@ -727,7 +727,10 @@ save (LV2_Handle instance, return LV2_STATE_ERR_NO_PROPERTY; } - LV2_State_Map_Path* map_path = NULL; + LV2_State_Map_Path* map_path = NULL; +#ifdef LV2_STATE__freePath + LV2_State_Free_Path* free_path = NULL; +#endif for (int i = 0; features[i]; ++i) { if (!strcmp (features[i]->URI, LV2_STATE__mapPath)) { @@ -743,9 +746,15 @@ save (LV2_Handle instance, store (handle, self->afs_sf2file, apath, strlen (apath) + 1, self->atom_Path, LV2_STATE_IS_POD); - -#ifndef _WIN32 // TODO need lilv_free() -- https://github.com/drobilla/lilv/issues/14 - free (apath); +#ifdef LV2_STATE__freePath + if (free_path) { + free_path->free_path (free_path->handle, apath); + } else +#endif +#ifndef _WIN32 // https://github.com/drobilla/lilv/issues/14 + { + free (apath); + } #endif return LV2_STATE_SUCCESS; @@ -764,12 +773,20 @@ restore (LV2_Handle instance, return LV2_STATE_ERR_UNKNOWN; } - LV2_State_Map_Path* map_path = NULL; + LV2_State_Map_Path* map_path = NULL; +#ifdef LV2_STATE__freePath + LV2_State_Free_Path* free_path = NULL; +#endif for (int i = 0; features[i]; ++i) { if (!strcmp (features[i]->URI, LV2_STATE__mapPath)) { map_path = (LV2_State_Map_Path*) features[i]->data; } +#ifdef LV2_STATE__freePath + else if (!strcmp(features[i]->URI, LV2_STATE__freePath)) { + free_path = (LV2_State_Free_Path*)features[i]->data; + } +#endif } if (!map_path) { @@ -784,11 +801,17 @@ restore (LV2_Handle instance, if (value) { char* apath = map_path->absolute_path (map_path->handle, (const char*) value); strncpy (self->queue_sf2_file_path, apath, 1023); - printf ("XXX %s -> %s\n", (const char*) value, apath); self->queue_sf2_file_path[1023] = '\0'; self->queue_reinit = true; -#ifndef _WIN32 // TODO need lilv_free() -- https://github.com/drobilla/lilv/issues/14 - free (apath); +#ifdef LV2_STATE__freePath + if (free_path) { + free_path->free_path (free_path->handle, apath); + } else +#endif +#ifndef _WIN32 // https://github.com/drobilla/lilv/issues/14 + { + free (apath); + } #endif } return LV2_STATE_SUCCESS;