diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-09-17 08:24:48 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-09-17 08:39:31 -0400 |
commit | 54b593ec3e7829583ce2fec3fe22dff512db07fb (patch) | |
tree | 45ea7d195f6644b46228b1acbd321e012853b8da /pango/pango-attributes.c | |
parent | 51b2b2231b85af7fe4ade4ec98129b28182f7148 (diff) | |
download | pango-54b593ec3e7829583ce2fec3fe22dff512db07fb.tar.gz |
Fix attr iterators with overlapping attributesfix-nested-attributes
This broke when PangoAttrIterator was changed to
use an array for the stack of current attributes, in
dec6c0868ef2c36. We were not always walking the array
in the right order. The first attribute to check is
at the *end* of the array.
This showed up as misrendering in epsilon_0 example
in gtk3-demo's text view markup demo.
Test included.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r-- | pango/pango-attributes.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 12942043..4f96135b 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -2003,7 +2003,7 @@ pango_attr_iterator_range (PangoAttrIterator *iterator, gboolean pango_attr_iterator_next (PangoAttrIterator *iterator) { - guint i; + int i; g_return_val_if_fail (iterator != NULL, FALSE); @@ -2016,19 +2016,14 @@ pango_attr_iterator_next (PangoAttrIterator *iterator) if (iterator->attribute_stack) { - for (i = 0; i < iterator->attribute_stack->len; i++) + for (i = iterator->attribute_stack->len - 1; i>= 0; i--) { const PangoAttribute *attr = g_ptr_array_index (iterator->attribute_stack, i); if (attr->end_index == iterator->start_index) - { - g_ptr_array_remove_index (iterator->attribute_stack, i); /* Can't use index_fast :( */; - i--; - } + g_ptr_array_remove_index (iterator->attribute_stack, i); /* Can't use index_fast :( */ else - { - iterator->end_index = MIN (iterator->end_index, attr->end_index); - } + iterator->end_index = MIN (iterator->end_index, attr->end_index); } } @@ -2136,14 +2131,14 @@ PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator, PangoAttrType type) { - guint i; + int i; g_return_val_if_fail (iterator != NULL, NULL); if (!iterator->attribute_stack) return NULL; - for (i = 0; i < iterator->attribute_stack->len; i++) + for (i = iterator->attribute_stack->len - 1; i>= 0; i--) { PangoAttribute *attr = g_ptr_array_index (iterator->attribute_stack, i); |