[gobject-introspection] Fix regression in g_irepository_get_info
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Fix regression in g_irepository_get_info
- Date: Thu, 21 Oct 2010 18:58:15 +0000 (UTC)
commit 3aa52816c50ed1610d93909b68b979c6853eeb0e
Author: Colin Walters <walters verbum org>
Date: Thu Oct 21 14:59:42 2010 -0400
Fix regression in g_irepository_get_info
Commit f97cc8687469f25752f79275 broke the lookup in
g_irepository_get_info; the passed offset is 0-based, then
we convert it to 1-based (and then back to 0 later...which needs
to be fixed).
girepository/girepository.c | 6 ++++--
girepository/girwriter.c | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 18ecafb..7ac407a 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -519,11 +519,13 @@ g_irepository_get_n_infos (GIRepository *repository,
* g_irepository_get_info:
* @repository: (allow-none): A #GIRepository, may be %NULL for the default
* @namespace_: Namespace to inspect
- * @index: Offset into namespace metadata for entry
+ * @index: 0-based offset into namespace metadata for entry
*
* This function returns a particular metadata entry in the
* given namespace @namespace_. The namespace must have
* already been loaded before calling this function.
+ * See g_irepository_get_n_infos() to find the maximum number of
+ * entries.
*
* Returns: (transfer full): #GIBaseInfo containing metadata
*/
@@ -543,7 +545,7 @@ g_irepository_get_info (GIRepository *repository,
g_return_val_if_fail (typelib != NULL, NULL);
- entry = g_typelib_get_dir_entry (typelib, index);
+ entry = g_typelib_get_dir_entry (typelib, index + 1);
if (entry == NULL)
return NULL;
return _g_info_new_full (entry->blob_type,
diff --git a/girepository/girwriter.c b/girepository/girwriter.c
index 48f1a5d..8c4fa2c 100644
--- a/girepository/girwriter.c
+++ b/girepository/girwriter.c
@@ -1349,6 +1349,7 @@ gir_writer_write (const char *filename,
const gchar *c_prefix;
const char *ns = namespace;
const char *version;
+ gint n_infos;
version = g_irepository_get_version (repository, ns);
@@ -1361,7 +1362,8 @@ gir_writer_write (const char *filename,
if (c_prefix)
xml_printf (xml, " c:prefix=\"%s\"", c_prefix);
- for (j = 0; j < g_irepository_get_n_infos (repository, ns); j++)
+ n_infos = g_irepository_get_n_infos (repository, ns);
+ for (j = 0; j < n_infos; j++)
{
GIBaseInfo *info = g_irepository_get_info (repository, ns, j);
switch (g_base_info_get_type (info))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]