summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <chergert@redhat.com>2022-08-18 14:09:26 -0700
committerChristian Hergert <chergert@redhat.com>2022-08-18 14:11:10 -0700
commit3e335c9e9257c05a000a891422f5cc28c1f77d4b (patch)
tree633dfa2903e6770dffffd712ff037d93aef0bbf7
parenta2bc201b853d717fe1d8484872c47685571112e6 (diff)
downloadlibpeas-3e335c9e9257c05a000a891422f5cc28c1f77d4b.tar.gz
engine: sort unresolved plugins at tail of queue
If we have a plugin we've added that we could not resolve all the dependencies for then push it to the tail of the queue. That way, further insertions of plugins are more likely to sort before the plugin. Otherwise, we can push the info to the head as it has no dependencies. This improves a situation in Builder where plugins that dependend on plugins which also had dependencies could end up loading in the wrong order.
-rw-r--r--libpeas/peas-engine.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index b6eee05..c0ccae8 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -144,12 +144,22 @@ plugin_info_add_sorted (GQueue *plugin_list,
}
}
- /* GLib changed only accepts NULL for
- * g_queue_insert_after() at version 2.44
- */
if (furthest_dep == NULL)
{
- g_queue_push_head (plugin_list, info);
+ /* If we have dependencies and we didn't find any matches yet,
+ * 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.
+ *
+ * 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);
+ else
+ g_queue_push_head (plugin_list, info);
return;
}