[gobject-introspection] baseinfo: don't abort when calling g_base_info_get_name() on a GITypeInfo. Fixes #96
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] baseinfo: don't abort when calling g_base_info_get_name() on a GITypeInfo. Fixes #96
- Date: Sat, 15 Dec 2018 23:42:12 +0000 (UTC)
commit 0cc1dcc0afd0424e79235ed3053bdbfb83f7adb0
Author: Christoph Reiter <reiter christoph gmail com>
Date: Sat Dec 15 00:18:23 2018 +0100
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.
girepository/gibaseinfo.c | 1 +
tests/repository/gitestrepo.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+)
---
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]