diff options
-rw-r--r-- | src/pluginuiinstance.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/pluginuiinstance.c b/src/pluginuiinstance.c index 908d746..3f1017a 100644 --- a/src/pluginuiinstance.c +++ b/src/pluginuiinstance.c @@ -38,7 +38,7 @@ slv2_ui_instantiate(SLV2Plugin plugin, { struct _SLV2UIInstance* result = NULL; - bool local_features = (features == NULL); + const bool local_features = (features == NULL); if (local_features) { features = malloc(sizeof(LV2_Feature)); ((LV2_Feature**)features)[0] = NULL; @@ -46,9 +46,9 @@ slv2_ui_instantiate(SLV2Plugin plugin, const char* const lib_uri = slv2_value_as_string(slv2_ui_get_binary_uri(ui)); const char* const lib_path = slv2_uri_to_path(lib_uri); - - if (!lib_path) + if (!lib_path) { return NULL; + } dlerror(); void* lib = dlopen(lib_path, RTLD_NOW); @@ -66,8 +66,8 @@ slv2_ui_instantiate(SLV2Plugin plugin, dlclose(lib); return NULL; } else { - - const char* bundle_path = slv2_uri_to_path(slv2_value_as_uri(slv2_ui_get_bundle_uri(ui))); + const char* bundle_uri = slv2_value_as_uri(slv2_ui_get_bundle_uri(ui)); + const char* bundle_path = slv2_uri_to_path(bundle_uri); for (uint32_t i = 0; true; ++i) { const LV2UI_Descriptor* ld = df(i); @@ -83,13 +83,14 @@ slv2_ui_instantiate(SLV2Plugin plugin, // Create SLV2UIInstance to return result = malloc(sizeof(struct _SLV2UIInstance)); result->lv2ui_descriptor = ld; - result->lv2ui_handle = ld->instantiate(ld, - slv2_value_as_uri(slv2_plugin_get_uri(plugin)), - (char*)bundle_path, - write_function, - controller, - &result->widget, - features); + result->lv2ui_handle = ld->instantiate( + ld, + slv2_value_as_uri(slv2_plugin_get_uri(plugin)), + (char*)bundle_path, + write_function, + controller, + &result->widget, + features); result->lib_handle = lib; break; } @@ -102,15 +103,15 @@ slv2_ui_instantiate(SLV2Plugin plugin, return NULL; } - // Failed to create a widget, but still got a handle - this means that - // the plugin is buggy + // Failed to create a widget, but still got a handle (buggy UI) if (result->widget == NULL) { slv2_ui_instance_free(result); return NULL; } - if (local_features) + if (local_features) { free((LV2_Feature**)features); + } return result; } |