summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Frécinaux <code@istique.net>2010-08-16 22:39:19 +0200
committerSteve Frécinaux <code@istique.net>2010-08-18 20:07:18 +0200
commit3ed944ed5f7a8231ba5c431d59e33f23dca56f87 (patch)
treedaf1d33ce61e749e63254771a786bd39e7c4f8ba
parent98ca5de2eeb098e5f256abd9938e5a40861b4f1e (diff)
downloadgobject-introspection-3ed944ed5f7a8231ba5c431d59e33f23dca56f87.tar.gz
Include the loaded version in g_irepository_enumerate_versions()
Logically speaking, the already loaded version of a namespace is part of the currently available versions, and can be forgotten if we only consider the versions available in GI_TYPELIB_PATH, as it could have been loaded using g_irepository_require_private(). As a side effect, it meant that bindings relying on enumerate_version() (like pygobject) were not able to require private versions through their classical requirement scheme. This patch fixes it by adding the loaded version to the unsorted list of available versions returned by g_irepository_enumerate_versions() This patch also uses g_list_prepend() instead of g_list_append() in that function. https://bugzilla.gnome.org/show_bug.cgi?id=625983
-rw-r--r--girepository/girepository.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 17d076d5..96a23e6f 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -1166,7 +1166,8 @@ find_namespace_latest (const gchar *namespace,
* @repository: (allow-none): the repository
* @namespace_: GI namespace, e.g. "Gtk"
*
- * Obtain a list of versions for @namespace_ in this @repository.
+ * Obtain an unordered list of versions (either currently loaded or
+ * available) for @namespace_ in this @repository.
*
* Returns: (element-type utf8) (transfer full): the array of versions.
*/
@@ -1177,6 +1178,7 @@ g_irepository_enumerate_versions (GIRepository *repository,
GList *ret = NULL;
GSList *search_path;
GSList *candidates, *link;
+ const gchar *loaded_version;
search_path = build_search_path_with_overrides ();
candidates = enumerate_namespace_versions (namespace_, search_path);
@@ -1185,10 +1187,19 @@ g_irepository_enumerate_versions (GIRepository *repository,
for (link = candidates; link; link = link->next)
{
struct NamespaceVersionCandidadate *candidate = link->data;
- ret = g_list_append (ret, g_strdup (candidate->version));
+ ret = g_list_prepend (ret, g_strdup (candidate->version));
free_candidate (candidate);
}
g_slist_free (candidates);
+
+ /* The currently loaded version of a namespace is also part of the
+ * available versions, as it could have been loaded using
+ * require_private().
+ */
+ loaded_version = g_irepository_get_version (NULL, namespace_);
+ if (loaded_version && !g_list_find_custom (ret, loaded_version, g_str_equal))
+ ret = g_list_prepend (ret, g_strdup (loaded_version));
+
return ret;
}