From 3fa183524e6fe5ad22d3ebc83b2a68197fd2d179 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 26 Jul 2015 23:59:36 -0700 Subject: [PATCH] girepository: Remove "optimization" for found prefixes This optimization is bugged and broken in the case of certain libraries. GNOME uses a lot of prefixes with "G", so we'll almost always have found the prefix. This is specifically a problem for something like GXml.xDocument, which uses a type name starting with a lower-case letter, which fools the prefix logic, but we're also fooled by the "G" appearing in GLib and Gio. A more sophisticated version of this check would have three passes: check prefix with type-case, check prefix without type-case, global search, but this is an edge case and it doesn't feel worth it to write. --- girepository.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/girepository.c b/girepository.c index 4291b7e3c..4723c951f 100644 --- a/girepository.c +++ b/girepository.c @@ -739,7 +739,6 @@ g_irepository_get_info (GIRepository *repository, typedef struct { const gchar *gtype_name; GITypelib *result_typelib; - gboolean found_prefix; } FindByGTypeData; static DirEntry * @@ -757,8 +756,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,7 +802,6 @@ g_irepository_find_by_gtype (GIRepository *repository, data.gtype_name = g_type_name (gtype); data.result_typelib = NULL; - data.found_prefix = FALSE; /* Inside each typelib, we include the "C prefix" which acts as * a namespace mechanism. For GtkTreeView, the C prefix is Gtk. @@ -818,13 +814,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.