diff options
author | Garrett Regier <garrettregier@gmail.com> | 2015-11-17 23:23:03 -0800 |
---|---|---|
committer | Garrett Regier <garrettregier@gmail.com> | 2015-12-15 16:57:46 -0800 |
commit | ddd65c849420fa390977971208c7a8ea2d8ea6a3 (patch) | |
tree | 0194bddcc77e5aeed59407748bcdbd17be3c0264 /libpeas | |
parent | b19f1cea0fdc5b91ed6ef6d40ff67f9dcd217eda (diff) | |
download | libpeas-ddd65c849420fa390977971208c7a8ea2d8ea6a3.tar.gz |
Order the PeasEngine:plugin-list by dependencies
Otherwise PeasExtensionSet could add an extension
for a plugin before that of a plugin it depends on.
https://bugzilla.gnome.org/show_bug.cgi?id=758446
Diffstat (limited to 'libpeas')
-rw-r--r-- | libpeas/peas-engine.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c index ccee8a6..65efd0d 100644 --- a/libpeas/peas-engine.c +++ b/libpeas/peas-engine.c @@ -124,6 +124,42 @@ static void peas_engine_load_plugin_real (PeasEngine *engine, static void peas_engine_unload_plugin_real (PeasEngine *engine, PeasPluginInfo *info); +static GList * +plugin_info_prepend_sorted (GList *plugin_list, + PeasPluginInfo *info) +{ + guint i; + GList *furthest_dep = NULL; + const gchar **dependencies; + + dependencies = peas_plugin_info_get_dependencies (info); + + for (i = 0; dependencies[i] != NULL; ++i) + { + GList *pos = furthest_dep != NULL ? furthest_dep : plugin_list; + + for (; pos != NULL; pos = pos->next) + { + if (strcmp (dependencies[i], + peas_plugin_info_get_module_name (pos->data)) == 0) + { + furthest_dep = pos; + break; + } + } + } + + if (furthest_dep == NULL) + return g_list_prepend (plugin_list, info); + + g_debug ("Adding '%s' after '%s' due to dependencies", + peas_plugin_info_get_module_name (info), + peas_plugin_info_get_module_name (furthest_dep->data)); + + g_list_insert (furthest_dep, info, 1); + return plugin_list; +} + static void load_plugin_info (PeasEngine *engine, const gchar *filename, @@ -144,20 +180,17 @@ load_plugin_info (PeasEngine *engine, return; } - /* If a plugin with this name has already been loaded - * drop this one (user plugins override system plugins) */ module_name = peas_plugin_info_get_module_name (info); if (peas_engine_get_plugin_info (engine, module_name) != NULL) { _peas_plugin_info_unref (info); + return; } - else - { - priv->plugin_list = g_list_prepend (priv->plugin_list, info); - g_object_notify_by_pspec (G_OBJECT (engine), - properties[PROP_PLUGIN_LIST]); - } + priv->plugin_list = plugin_info_prepend_sorted (priv->plugin_list, info); + + g_object_notify_by_pspec (G_OBJECT (engine), + properties[PROP_PLUGIN_LIST]); } static void |