diff --git a/src/libaudcore/plugin-registry.cc b/src/libaudcore/plugin-registry.cc index d5d72a603..9978d7f4d 100644 --- a/src/libaudcore/plugin-registry.cc +++ b/src/libaudcore/plugin-registry.cc @@ -103,6 +103,7 @@ static constexpr aud::array input_key_names = { static aud::array> plugins; static aud::array> compatible; +static aud::array> sorted; /* by name */ static aud::mutex mutex; static bool modified = false; @@ -209,6 +210,9 @@ void plugin_registry_cleanup() for (auto & list : compatible) list.clear(); + + for (auto & list : sorted) + list.clear(); } static void transport_plugin_parse(PluginHandle * plugin, TextParser & parser) @@ -442,8 +446,14 @@ void plugin_registry_prune() { plugins[type].remove_if(check_not_found); plugins[type].sort(plugin_compare); + compatible[type].insert(plugins[type].begin(), 0, plugins[type].len()); compatible[type].remove_if(check_incompatible); + + sorted[type].insert(compatible[type].begin(), 0, compatible[type].len()); + sorted[type].sort([](PluginHandle * a, PluginHandle * b) { + return str_compare(aud_plugin_get_name(a), aud_plugin_get_name(b)); + }); } } @@ -623,6 +633,11 @@ EXPORT const Index & aud_plugin_list(PluginType type) return compatible[type]; } +EXPORT const Index & aud_plugin_list_sorted(PluginType type) +{ + return sorted[type]; +} + EXPORT const char * aud_plugin_get_name(PluginHandle * plugin) { return dgettext(plugin->domain, plugin->name); diff --git a/src/libaudcore/plugins.h b/src/libaudcore/plugins.h index bf156f6d8..2cc60ba89 100644 --- a/src/libaudcore/plugins.h +++ b/src/libaudcore/plugins.h @@ -57,6 +57,7 @@ const void * aud_plugin_get_header(PluginHandle * plugin); PluginHandle * aud_plugin_by_header(const void * header); const Index & aud_plugin_list(PluginType type); +const Index & aud_plugin_list_sorted(PluginType type); const char * aud_plugin_get_name(PluginHandle * plugin); bool aud_plugin_has_about(PluginHandle * plugin); diff --git a/src/libaudgui/plugin-view.cc b/src/libaudgui/plugin-view.cc index 2939c680e..e168f9315 100644 --- a/src/libaudgui/plugin-view.cc +++ b/src/libaudgui/plugin-view.cc @@ -132,7 +132,7 @@ static void list_fill (GtkTreeView * tree, void * type) gtk_tree_view_column_pack_start (col, rend, false); gtk_tree_view_column_set_attributes (col, rend, "text", PVIEW_COL_NAME, nullptr); - for (PluginHandle * plugin : aud_plugin_list (aud::from_ptr (type))) + for (PluginHandle * plugin : aud_plugin_list_sorted (aud::from_ptr (type))) add_to_list (model, plugin); } diff --git a/src/libaudqt/prefs-pluginlist-model.cc b/src/libaudqt/prefs-pluginlist-model.cc index e86b43607..efc5f15cc 100644 --- a/src/libaudqt/prefs-pluginlist-model.cc +++ b/src/libaudqt/prefs-pluginlist-model.cc @@ -72,7 +72,7 @@ QModelIndex PluginListModel::index(int row, int column, if (cat < 0 || cat >= n_categories) return QModelIndex(); - auto & list = aud_plugin_list(categories[cat].type); + auto & list = aud_plugin_list_sorted(categories[cat].type); if (row < 0 || row >= list.len()) return QModelIndex();