summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-12-15 00:18:23 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2018-12-15 23:33:32 +0000
commit0cc1dcc0afd0424e79235ed3053bdbfb83f7adb0 (patch)
treea942356f7a34e4a1380787a5f56886ba8d72000d
parent3e0c101aeb102071d50215cbdc928f41415b2307 (diff)
downloadgobject-introspection-0cc1dcc0afd0424e79235ed3053bdbfb83f7adb0.tar.gz
baseinfo: don't abort when calling g_base_info_get_name() on a GITypeInfo. Fixes #96
GITypeInfo is a GIBaseInfo so calling g_base_info_get_name() on it should do something sensible. g_base_info_get_name() has always been documented to return NULL in case no name is available so return that instead.
-rw-r--r--girepository/gibaseinfo.c1
-rw-r--r--tests/repository/gitestrepo.c25
2 files changed, 26 insertions, 0 deletions
diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c
index ced7674e..e47d5390 100644
--- a/girepository/gibaseinfo.c
+++ b/girepository/gibaseinfo.c
@@ -377,6 +377,7 @@ g_base_info_get_name (GIBaseInfo *info)
}
break;
case GI_INFO_TYPE_TYPE:
+ return NULL;
default: ;
g_assert_not_reached ();
/* unnamed */
diff --git a/tests/repository/gitestrepo.c b/tests/repository/gitestrepo.c
index 281a5f3b..6c10b076 100644
--- a/tests/repository/gitestrepo.c
+++ b/tests/repository/gitestrepo.c
@@ -34,6 +34,29 @@ test_constructor_return_type(GIBaseInfo* object_info)
g_assert (strcmp (class_name, return_name) == 0);
}
+static void
+test_type_info_get_name (GIRepository *repo)
+{
+ GIBaseInfo *base;
+ GIVFuncInfo *vfunc;
+ GITypeInfo *typeinfo;
+
+ base = g_irepository_find_by_name (repo, "Gio", "File");
+ g_assert_nonnull (base);
+ g_assert_true (GI_IS_INTERFACE_INFO (base));
+ vfunc = g_interface_info_find_vfunc ((GIInterfaceInfo*)base, "read_async");
+ g_assert_nonnull (vfunc);
+ g_base_info_unref ((GIBaseInfo*)base);
+
+ typeinfo = g_callable_info_get_return_type (vfunc);
+ g_assert_nonnull (typeinfo);
+ g_base_info_unref ((GIBaseInfo*)vfunc);
+
+ /* https://gitlab.gnome.org/GNOME/gobject-introspection/issues/96 */
+ g_assert_null (g_base_info_get_name (typeinfo));
+ g_base_info_unref ((GIBaseInfo*)typeinfo);
+}
+
int
main(int argc, char **argv)
@@ -137,6 +160,8 @@ main(int argc, char **argv)
g_assert (strcmp (g_base_info_get_name ((GIBaseInfo*)invoker), "get_display") == 0);
}
+ test_type_info_get_name (repo);
+
/* Error quark tests */
errorinfo = g_irepository_find_by_error_domain (repo, G_RESOLVER_ERROR);
g_assert (errorinfo != NULL);