summaryrefslogtreecommitdiff
path: root/libpeas/peas-engine.c
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2022-08-18 15:41:37 -0700
committerChristian Hergert <chergert@redhat.com>2022-08-18 15:41:37 -0700
commit5e93a10bb42ffe600248dabcb082165c6862dff2 (patch)
tree3771072ca817abde10fa265bd4396add1d6cd85d /libpeas/peas-engine.c
parent8007883516f44f2d6da65a0d4998c43e44f464ba (diff)
downloadlibpeas-5e93a10bb42ffe600248dabcb082165c6862dff2.tar.gz
engine: check reverse dependencies for unresolved infos
If we have unresolved plugin info, we might need to place the item sooner than the tail as another plugin could depend on this one.
Diffstat (limited to 'libpeas/peas-engine.c')
-rw-r--r--libpeas/peas-engine.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index a2202a5..277bf2b 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -150,17 +150,42 @@ plugin_info_add_sorted (GQueue *plugin_list,
* then push the item to the tail to improve the chances that
* the dependencies will resolve in the proper order. Otherwise
* a plugin that has dependency (which also has a dependency)
- * can resolve in the wrong order.
+ * can resolve in the wrong order. To slightly improve on this
+ * we can also look for any plugins that depend on this and
+ * insert it before that iter.
*
* Another option here is to do proper dependency solving but
* the way things are designed to do resolving at each info
* load means that we'd do the depsolve more than necessary.
*/
- if (dependencies[0] != NULL)
- g_queue_push_tail (plugin_list, info);
+ if (dependencies[0] == NULL)
+ {
+ g_queue_push_head (plugin_list, info);
+ return;
+ }
else
- g_queue_push_head (plugin_list, info);
- return;
+ {
+ const char *module_name = peas_plugin_info_get_module_name (info);
+ GList *iter;
+
+ for (iter = plugin_list->head; iter; iter = iter->next)
+ {
+ const PeasPluginInfo *other = iter->data;
+ const char **other_dependencies = peas_plugin_info_get_dependencies (other);
+
+ for (i = 0; other_dependencies[i] != NULL; i++)
+ {
+ if (strcmp (other_dependencies[i], module_name) == 0)
+ {
+ g_queue_insert_before (plugin_list, iter, info);
+ return;
+ }
+ }
+ }
+
+ g_queue_push_tail (plugin_list, info);
+ return;
+ }
}
g_debug ("Adding '%s' after '%s' due to dependencies",