summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-10-21 14:59:42 -0400
committerColin Walters <walters@verbum.org>2010-10-21 15:01:07 -0400
commit3aa52816c50ed1610d93909b68b979c6853eeb0e (patch)
tree7761c2519b5db8ccc298e4b188b1a874c44d6d11
parent78716bd269a1b2b770138b3ce5e00f2a9f479b55 (diff)
downloadgobject-introspection-3aa52816c50ed1610d93909b68b979c6853eeb0e.tar.gz
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).
-rw-r--r--girepository/girepository.c6
-rw-r--r--girepository/girwriter.c4
2 files changed, 7 insertions, 3 deletions
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 18ecafbe..7ac407a1 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 48f1a5d2..8c4fa2c3 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))