[libpeas] Fix sorting of PeasEngine:plugin-list



commit 5ac602a782ff18ab7f56a5ed546aa24cc1f6c13d
Author: Garrett Regier <garrettregier gmail com>
Date:   Sat Dec 19 14:53:35 2015 -0800

    Fix sorting of PeasEngine:plugin-list
    
    The new "better order" ended up breaking the
    order to be correct in regards to dependencies.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759613

 libpeas/peas-engine.c                 |    8 ++++----
 tests/libpeas/engine.c                |    6 +++---
 tests/libpeas/plugins/two-deps.plugin |    2 +-
 tests/testing-util/testing-util.c     |   11 +++++++++++
 4 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 2ae6e07..f56cd37 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -125,8 +125,8 @@ static void peas_engine_unload_plugin_real (PeasEngine     *engine,
                                             PeasPluginInfo *info);
 
 static void
-plugin_info_prepend_sorted (GQueue         *plugin_list,
-                            PeasPluginInfo *info)
+plugin_info_add_sorted (GQueue         *plugin_list,
+                        PeasPluginInfo *info)
 {
   guint i;
   GList *furthest_dep = NULL;
@@ -154,7 +154,7 @@ plugin_info_prepend_sorted (GQueue         *plugin_list,
    */
   if (furthest_dep == NULL)
     {
-      g_queue_push_tail (plugin_list, info);
+      g_queue_push_head (plugin_list, info);
       return;
     }
 
@@ -192,7 +192,7 @@ load_plugin_info (PeasEngine  *engine,
       return FALSE;
     }
 
-  plugin_info_prepend_sorted (&priv->plugin_list, info);
+  plugin_info_add_sorted (&priv->plugin_list, info);
   g_object_notify_by_pspec (G_OBJECT (engine),
                             properties[PROP_PLUGIN_LIST]);
 
diff --git a/tests/libpeas/engine.c b/tests/libpeas/engine.c
index 26bdc43..0c975f4 100644
--- a/tests/libpeas/engine.c
+++ b/tests/libpeas/engine.c
@@ -286,9 +286,9 @@ test_engine_plugin_list (PeasEngine *engine)
 
   /* Verify that we are finding the furthest dependency in the list */
   dependencies = peas_plugin_info_get_dependencies (two_deps_info);
-  g_assert_cmpint (builtin_index, <, loadable_index);
-  g_assert_cmpstr (dependencies[0], ==, "builtin");
-  g_assert_cmpstr (dependencies[1], ==, "loadable");
+  g_assert_cmpint (builtin_index, >, loadable_index);
+  g_assert_cmpstr (dependencies[0], ==, "loadable");
+  g_assert_cmpstr (dependencies[1], ==, "builtin");
 
   /* The two-deps plugin should be ordered after builtin and loadable */
   g_assert_cmpint (builtin_index, <, two_deps_index);
diff --git a/tests/libpeas/plugins/two-deps.plugin b/tests/libpeas/plugins/two-deps.plugin
index 0231c27..b463a82 100644
--- a/tests/libpeas/plugins/two-deps.plugin
+++ b/tests/libpeas/plugins/two-deps.plugin
@@ -1,6 +1,6 @@
 [Plugin]
 Module=two-deps
-Depends=builtin;loadable
+Depends=loadable;builtin
 Name=Two Deps
 Description=This plugin cannot be loaded and has two deps.
 Authors=Garrett Regier
diff --git a/tests/testing-util/testing-util.c b/tests/testing-util/testing-util.c
index 4763e46..1f167a9 100644
--- a/tests/testing-util/testing-util.c
+++ b/tests/testing-util/testing-util.c
@@ -249,6 +249,17 @@ testing_util_engine_new_full (gboolean nonglobal_loaders)
                      (GWeakNotify) engine_weak_notify,
                      NULL);
 
+  /* The plugins that two-deps depends on must be added
+   * to the engine before it. This is used to verify that
+   * the engine will order the plugin list correctly.
+   */
+  peas_engine_add_search_path (engine,
+                               BUILDDIR "/tests/plugins/builtin",
+                               SRCDIR   "/tests/plugins/builtin");
+  peas_engine_add_search_path (engine,
+                               BUILDDIR "/tests/plugins/loadable",
+                               SRCDIR   "/tests/plugins/loadable");
+
   peas_engine_add_search_path (engine,
                                BUILDDIR "/tests/plugins",
                                SRCDIR   "/tests/plugins");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]