[pango/wip/baedert/for-master2: 17/17] layout: Treat empty attr lists like NULL ones



commit ea6248f5195bcfb1f11a20c7edb5fae6ab85e64d
Author: Timm Bäder <mail baedert org>
Date:   Mon Jun 8 19:20:14 2020 +0200

    layout: Treat empty attr lists like NULL ones

 pango/pango-attributes.c | 2 +-
 pango/pango-layout.c     | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 84d24838..97c7aeaf 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1992,7 +1992,7 @@ pango_attr_list_equal (PangoAttrList *list,
 gboolean
 _pango_attr_list_has_attributes (const PangoAttrList *list)
 {
-  return (list->attributes != NULL);
+  return list && (list->attributes != NULL);
 }
 
 G_DEFINE_BOXED_TYPE (PangoAttrIterator,
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 11e14418..7824a3ce 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -685,9 +685,15 @@ pango_layout_set_attributes (PangoLayout   *layout,
 
   g_return_if_fail (layout != NULL);
 
+  /* Both empty */
   if (!attrs && !layout->attrs)
     return;
 
+  /* Also both empty */
+  if (!_pango_attr_list_has_attributes (layout->attrs) &&
+      !_pango_attr_list_has_attributes (attrs))
+    return;
+
   old_attrs = layout->attrs;
 
   /* We always clear lines such that this function can be called


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