[pango/line-breaker] attributes: Handle custom attributes



commit 48ba0b8c7a34ec7b2ef8934a9d6697c2c7f6867d
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jan 25 20:49:25 2022 -0500

    attributes: Handle custom attributes
    
    We should not segfault when printing a
    PangoAttrList containing some attributes
    that have been registered by gtk.

 pango/pango-attributes.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 6f50d3fe..8d93e5ab 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -2610,7 +2610,10 @@ get_attr_type_nick (PangoAttrType attr_type)
   enum_value = g_enum_get_value (enum_class, attr_type);
   g_type_class_unref (enum_class);
 
-  return enum_value->value_nick;
+  if (enum_value)
+    return enum_value->value_nick;
+  else
+    return pango_attr_type_get_name (attr_type);
 }
 
 static GType
@@ -2716,6 +2719,10 @@ attr_print (GString        *str,
     g_string_append_printf (str, " %d", size->size);
   else if ((features = pango_attribute_as_font_features (attr)) != NULL)
     g_string_append_printf (str, " \"%s\"", features->features);
+  else if (pango_attr_type_get_name (attr->klass->type))
+    {
+      g_string_append (str, "NONE");
+    }
   else
     {
       g_warning ("Unhandled attribute type %s (%d)\n",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]