From 8a08674b33961ba531fa65d6a30bbf24fb96d427 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 28 Apr 2016 16:22:38 +0200 Subject: [PATCH] girepository: Merge overrides with the regular search path This reverts commit e81c4681cc88a00fcd841c5a68d860d3714b55d7 The GI_TYPELIB_PATH envvar will still allow overriding the default typelib dir (based on gobject-introspection libdir), but applications will have the last say about typelib lookup directories. The resulting lookup order is now: - Paths added through g_irepository_prepend_search_path() - Paths in GI_TYPELIB_PATH - The default gobject introspection lookup dir This makes g_irespository_prepend_search_path() work as announced despite environment variables. If any application was relying on GI_TYPELIB_PATH overriding the paths of this function call (for e.g. make check, or to be able to run code inside the project tree), it is encouraged to set up a similar envvar for their application specific lookup dir, or perform this override through other means. https://bugzilla.gnome.org/show_bug.cgi?id=765735 --- girepository.c | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/girepository.c b/girepository.c index 4537c03d7..d9f8f6c34 100644 --- a/girepository.c +++ b/girepository.c @@ -46,7 +46,6 @@ static GIRepository *default_repository = NULL; static GSList *search_path = NULL; -static GSList *override_search_path = NULL; struct _GIRepositoryPrivate { @@ -163,7 +162,6 @@ init_globals (void) type_lib_path_env = g_getenv ("GI_TYPELIB_PATH"); search_path = NULL; - override_search_path = NULL; if (type_lib_path_env) { gchar **custom_dirs; @@ -174,7 +172,7 @@ init_globals (void) d = custom_dirs; while (*d) { - override_search_path = g_slist_prepend (override_search_path, *d); + search_path = g_slist_prepend (search_path, *d); d++; } @@ -182,9 +180,6 @@ init_globals (void) g_free (custom_dirs); } - if (override_search_path != NULL) - override_search_path = g_slist_reverse (override_search_path); - libdir = GOBJECT_INTROSPECTION_LIBDIR; typelib_dir = g_build_filename (libdir, "girepository-1.0", NULL); @@ -227,23 +222,6 @@ g_irepository_get_search_path (void) return search_path; } -static GSList * -build_search_path_with_overrides (void) -{ - GSList *result; - - init_globals (); - - if (override_search_path != NULL) - { - result = g_slist_copy (override_search_path); - g_slist_last (result)->next = g_slist_copy (search_path); - } - else - result = g_slist_copy (search_path); - return result; -} - static char * build_typelib_key (const char *name, const char *source) { @@ -1394,13 +1372,11 @@ g_irepository_enumerate_versions (GIRepository *repository, const gchar *namespace_) { GList *ret = NULL; - GSList *search_path; GSList *candidates, *link; const gchar *loaded_version; - search_path = build_search_path_with_overrides (); + init_globals (); candidates = enumerate_namespace_versions (namespace_, search_path); - g_slist_free (search_path); for (link = candidates; link; link = link->next) { @@ -1563,13 +1539,11 @@ g_irepository_require (GIRepository *repository, GIRepositoryLoadFlags flags, GError **error) { - GSList *search_path; GITypelib *typelib; - search_path = build_search_path_with_overrides (); + init_globals (); typelib = require_internal (repository, namespace, version, flags, search_path, error); - g_slist_free (search_path); return typelib; }