Imported Upstream version 1.49.1
[platform/upstream/gobject-introspection.git] / girepository / girepository.c
index 93382fd..d9f8f6c 100644 (file)
@@ -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)
 {
@@ -546,12 +524,12 @@ g_irepository_get_dependencies (GIRepository *repository,
   g_return_val_if_fail (namespace != NULL, NULL);
 
   repository = get_repository (repository);
-  transitive_dependencies = g_hash_table_new_full (g_str_hash, g_str_equal,
-                                                   g_free, NULL);
 
-  /* Load the dependencies. */
   typelib = get_registered (repository, namespace, NULL);
   g_return_val_if_fail (typelib != NULL, NULL);
+
+  /* Load the dependencies. */
+  transitive_dependencies = g_hash_table_new (g_str_hash, g_str_equal);
   get_typelib_dependencies_transitive (repository, typelib,
                                        transitive_dependencies);
 
@@ -566,6 +544,8 @@ g_irepository_get_dependencies (GIRepository *repository,
       g_hash_table_iter_steal (&iter);
     }
 
+  g_hash_table_unref (transitive_dependencies);
+
   /* Add a NULL terminator. */
   g_ptr_array_add (out, NULL);
 
@@ -739,7 +719,6 @@ g_irepository_get_info (GIRepository *repository,
 typedef struct {
   const gchar *gtype_name;
   GITypelib *result_typelib;
-  gboolean found_prefix;
 } FindByGTypeData;
 
 static DirEntry *
@@ -757,8 +736,6 @@ find_by_gtype (GHashTable *table, FindByGTypeData *data, gboolean check_prefix)
         {
           if (!g_typelib_matches_gtype_name_prefix (typelib, data->gtype_name))
             continue;
-
-          data->found_prefix = TRUE;
         }
 
       ret = g_typelib_get_dir_entry_by_gtype_name (typelib, data->gtype_name);
@@ -805,19 +782,6 @@ g_irepository_find_by_gtype (GIRepository *repository,
 
   data.gtype_name = g_type_name (gtype);
   data.result_typelib = NULL;
-  data.found_prefix = FALSE;
-
-  /* There is a corner case regarding GdkRectangle.  GdkRectangle is a
-   * boxed type, but it is just an alias to boxed struct
-   * CairoRectangleInt.  Scanner automatically converts all references
-   * to GdkRectangle to CairoRectangleInt, so GdkRectangle does not
-   * appear in the typelibs at all, although user code might query it.
-   * So if we get such query, we also change it to lookup of
-   * CairoRectangleInt.
-   * https://bugzilla.gnome.org/show_bug.cgi?id=655423
-   */
-  if (G_UNLIKELY (!strcmp (data.gtype_name, "GdkRectangle")))
-    data.gtype_name = "CairoRectangleInt";
 
   /* Inside each typelib, we include the "C prefix" which acts as
    * a namespace mechanism.  For GtkTreeView, the C prefix is Gtk.
@@ -830,13 +794,6 @@ g_irepository_find_by_gtype (GIRepository *repository,
   if (entry == NULL)
     entry = find_by_gtype (repository->priv->lazy_typelibs, &data, TRUE);
 
-  /* If we have no result, but we did find a typelib claiming to
-   * offer bindings for such a prefix, bail out now on the assumption
-   * that a more exhaustive search would not produce any results.
-   */
-  if (entry == NULL && data.found_prefix)
-      return NULL;
-
   /* Not ever class library necessarily specifies a correct c_prefix,
    * so take a second pass. This time we will try a global lookup,
    * ignoring prefixes.
@@ -1415,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)
     {
@@ -1584,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;
 }