diff options
author | Christian Hergert <chergert@redhat.com> | 2022-08-18 13:51:45 -0700 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2022-08-18 14:11:10 -0700 |
commit | a2bc201b853d717fe1d8484872c47685571112e6 (patch) | |
tree | c05c385e5681f3188bbd2042b1402caea284c31d | |
parent | c14946e86df4d530a547bb6822a82e5edefabba5 (diff) | |
download | libpeas-a2bc201b853d717fe1d8484872c47685571112e6.tar.gz |
engine: improve reproducibility of resource-based plugins
We don't have guarantees that the children will be in a predictable order,
which can be annoying for tracking down issues users have that the
developer cannot reproduce. This just normalizes things so that we can be
more sure that the issues will be predictable.
-rw-r--r-- | libpeas/peas-engine.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c index 9929f69..b6eee05 100644 --- a/libpeas/peas-engine.c +++ b/libpeas/peas-engine.c @@ -23,6 +23,7 @@ #include "config.h" +#include <stdlib.h> #include <string.h> #include "peas-i18n-priv.h" @@ -241,6 +242,16 @@ load_file_dir_real (PeasEngine *engine, return found; } +static int +strptrcmp (gconstpointer a, + gconstpointer b) +{ + const char * const *stra = a; + const char * const *strb = b; + + return strcmp (*stra, *strb); +} + static gboolean load_resource_dir_real (PeasEngine *engine, const gchar *module_dir, @@ -267,6 +278,9 @@ load_resource_dir_real (PeasEngine *engine, return FALSE; } + /* Always sort resource children for improved reproducibility */ + qsort (children, g_strv_length (children), sizeof (char *), strptrcmp); + for (i = 0; children[i] != NULL; ++i) { gboolean is_dir; |