Skip to content

Commit

Permalink
show warning when attempting to open deprecated LV2 UIs in non-bridge…
Browse files Browse the repository at this point in the history
… mode)
  • Loading branch information
alex-tee committed Jan 18, 2021
1 parent 0581c4a commit ecf61f9
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 2 deletions.
13 changes: 12 additions & 1 deletion inc/plugins/lv2_plugin.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Alexandros Theodotou <alex at zrythm dot org>
* Copyright (C) 2018-2021 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
Expand Down Expand Up @@ -364,6 +364,17 @@ typedef enum Lv2PluginPickUiFlag
LV2_PLUGIN_UI_FOR_BRIDGING,
} Lv2PluginPickUiFlag;

/**
* Returns whether the plugin has a custom UI that
* is deprecated (GtkUI, QtUI, etc.).
*
* @return If the plugin has a deprecated UI,
* returns the UI URI, otherwise NULL.
*/
char *
lv2_plugin_has_deprecated_ui (
const char * uri);

/**
* Pick the most preferable UI.
*
Expand Down
71 changes: 70 additions & 1 deletion src/plugins/lv2_plugin.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Alexandros Theodotou <alex at zrythm dot org>
* Copyright (C) 2018-2021 Alexandros Theodotou <alex at zrythm dot org>
*
* This file is part of Zrythm
*
Expand Down Expand Up @@ -1164,6 +1164,11 @@ lv2_plugin_create_descriptor_from_lilv (
str = lilv_node_as_string (author);
pd->author = g_strdup (str);
lilv_node_free (author);
LilvNode * website =
lilv_plugin_get_author_homepage (lp);
str = lilv_node_as_string (website);
pd->website = g_strdup (str);
lilv_node_free (website);
const LilvPluginClass* pclass =
lilv_plugin_get_class(lp);
const LilvNode * label =
Expand Down Expand Up @@ -1411,6 +1416,70 @@ lv2_plugin_ui_type_is_external (
ui_type, PM_LILV_NODES.ui_external);
}

/**
* Returns whether the plugin has a custom UI that
* is deprecated (GtkUI, QtUI, etc.).
*
* @return If the plugin has a deprecated UI,
* returns the UI URI, otherwise NULL.
*/
char *
lv2_plugin_has_deprecated_ui (
const char * uri)
{
LilvNode * lv2_uri =
lilv_new_uri (LILV_WORLD, uri);
const LilvPlugin * lilv_plugin =
lilv_plugins_get_by_uri (
PM_LILV_NODES.lilv_plugins,
lv2_uri);
lilv_node_free (lv2_uri);
const LilvUI * ui;
const LilvNode * ui_type;
LilvUIs * uis =
lilv_plugin_get_uis (lilv_plugin);
bool ui_picked =
lv2_plugin_pick_ui (
uis, LV2_PLUGIN_UI_WRAPPABLE,
&ui, &ui_type);
if (!ui_picked)
{
ui_picked =
lv2_plugin_pick_ui (
uis, LV2_PLUGIN_UI_EXTERNAL,
&ui, &ui_type);
}
if (!ui_picked)
{
ui_picked =
lv2_plugin_pick_ui (
uis, LV2_PLUGIN_UI_FOR_BRIDGING,
&ui, &ui_type);
}
if (!ui_picked)
{
return false;
}

const char * ui_type_str =
lilv_node_as_string (ui_type);
char * ret = NULL;
if (lilv_node_equals (
ui_type, PM_LILV_NODES.ui_GtkUI) ||
lilv_node_equals (
ui_type, PM_LILV_NODES.ui_Gtk3UI) ||
lilv_node_equals (
ui_type, PM_LILV_NODES.ui_Qt5UI) ||
lilv_node_equals (
ui_type, PM_LILV_NODES.ui_Qt4UI))
{
ret = g_strdup (ui_type_str);
}
lilv_uis_free (uis);

return ret;
}

/**
* Pick the most preferable UI.
*
Expand Down
30 changes: 30 additions & 0 deletions src/plugins/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,36 @@ plugin_open_ui (
return;
}

/* show error if LV2 UI type is deprecated */
if (self->descr->protocol == PROT_LV2 &&
(!self->descr->open_with_carla ||
self->descr->bridge_mode !=
CARLA_BRIDGE_FULL))
{
char * deprecated_uri =
lv2_plugin_has_deprecated_ui (
self->descr->uri);
if (deprecated_uri)
{
char msg[1200];
sprintf (
msg,
_("%s <%s> has a deprecated UI "
"type:\n %s\n"
"If the UI does not load, please try "
"instantiating the plugin in full-"
"bridged mode, and report this to the "
"author:\n %s <%s>"),
self->descr->name,
self->descr->uri,
deprecated_uri, self->descr->author,
self->descr->website);
ui_show_error_message (
MAIN_WINDOW, msg);
g_free (deprecated_uri);
}
}

if (self->descr->open_with_carla)
{
#ifdef HAVE_CARLA
Expand Down

0 comments on commit ecf61f9

Please sign in to comment.