diff options
author | Colin Walters <walters@verbum.org> | 2010-08-25 13:14:57 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-08-31 16:05:57 -0400 |
commit | b816bf21bfbf4dbfa35d4bc5987c2a3006478aea (patch) | |
tree | cc7c992f64ab698080048eb34fe26aca0474c064 | |
parent | 9c0ed701aa1961efe931fbded530cacffe036491 (diff) | |
download | gobject-introspection-b816bf21bfbf4dbfa35d4bc5987c2a3006478aea.tar.gz |
scanner: Avoid internal invalid Type instances from parents
We were adding a trailing ',' in the parent string, clean that up; and
don't attempt to create a Type from the empty string.
-rw-r--r-- | girepository/gdump.c | 16 | ||||
-rw-r--r-- | giscanner/gdumpparser.py | 5 |
2 files changed, 11 insertions, 10 deletions
diff --git a/girepository/gdump.c b/girepository/gdump.c index 3dc21728..84ac3c71 100644 --- a/girepository/gdump.c +++ b/girepository/gdump.c @@ -168,17 +168,17 @@ dump_object_type (GType type, const char *symbol, GOutputStream *out) GType parent; gboolean first = TRUE; - parent = type; + parent = g_type_parent (type); parent_str = g_string_new (""); - do + while (parent != G_TYPE_OBJECT && parent != G_TYPE_INVALID) { - parent = g_type_parent (parent); if (first) first = FALSE; else g_string_append_c (parent_str, ','); g_string_append (parent_str, g_type_name (parent)); - } while (parent != G_TYPE_OBJECT && parent != G_TYPE_INVALID); + parent = g_type_parent (parent); + } escaped_printf (out, " parents=\"%s\"", parent_str->str); @@ -299,11 +299,10 @@ dump_fundamental_type (GType type, const char *symbol, GOutputStream *out) if (G_TYPE_IS_INSTANTIATABLE (type)) escaped_printf (out, " instantiatable=\"1\""); - parent = type; + parent = g_type_parent (type); parent_str = g_string_new (""); - do + while (parent != G_TYPE_INVALID) { - parent = g_type_parent (parent); if (first) first = FALSE; else @@ -311,7 +310,8 @@ dump_fundamental_type (GType type, const char *symbol, GOutputStream *out) if (!g_type_name (parent)) break; g_string_append (parent_str, g_type_name (parent)); - } while (parent != G_TYPE_INVALID); + parent = g_type_parent (parent); + } if (parent_str->len > 0) escaped_printf (out, " parents=\"%s\"", parent_str->str); diff --git a/giscanner/gdumpparser.py b/giscanner/gdumpparser.py index 30f9d6a9..ce6f9a25 100644 --- a/giscanner/gdumpparser.py +++ b/giscanner/gdumpparser.py @@ -362,9 +362,10 @@ blob containing data gleaned from GObject's primitive introspection.""" node.signals = node.signals def _parse_parents(self, xmlnode, node): - if 'parents' in xmlnode.attrib: + parents_str = xmlnode.attrib.get('parents', '') + if parents_str != '': parent_types = map(lambda s: self._transformer.create_type_from_user_string(s), - xmlnode.attrib['parents'].split(',')) + parents_str.split(',')) else: parent_types = [] node.parent_chain = parent_types |