[pango/wip/baedert/for-master] layout: Handle empty attr lists like NULL ones



commit 9289ed38efd3d9b9868917fd09ef6de29d84449a
Author: Timm Bäder <mail baedert org>
Date:   Fri Apr 17 21:19:04 2020 +0200

    layout: Handle empty attr lists like NULL ones
    
    I.e. don't invalidate the layout if setting from empty to empty.

 pango/pango-attributes.c | 2 +-
 pango/pango-layout.c     | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 6ba41e24..41f33f92 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1840,7 +1840,7 @@ pango_attr_list_get_attributes (PangoAttrList *list)
 gboolean
 _pango_attr_list_has_attributes (const PangoAttrList *list)
 {
-  return (list->attributes2 != NULL && list->attributes2->len > 0);
+  return list && (list->attributes2 != NULL && list->attributes2->len > 0);
 }
 
 G_DEFINE_BOXED_TYPE (PangoAttrIterator,
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index f36ae588..0230eb6e 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -685,7 +685,13 @@ pango_layout_set_attributes (PangoLayout   *layout,
 
   g_return_if_fail (layout != NULL);
 
-  if (!attrs && !layout->attrs)
+  /* Both empty */
+  if (!layout->attrs && !attrs)
+    return;
+
+  /* Both empty */
+  if (!_pango_attr_list_has_attributes (layout->attrs) &&
+      !_pango_attr_list_has_attributes (attrs))
     return;
 
   old_attrs = layout->attrs;


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