Evas textblock: Fix infinite loop case
authorDaniel Hirt <daniel.hirt@samsung.com>
Sun, 28 Jun 2015 12:02:28 +0000 (15:02 +0300)
committerDaniel Hirt <daniel.hirt@samsung.com>
Mon, 29 Jun 2015 13:43:49 +0000 (16:43 +0300)
This fixes a case with wrapping, where the text has a mixture of 'none'
and 'word' wrapping modes, and the layout function decides to
roll-back a few items.
The test case is added to the evas_suite.
This might not be a common case, or even a case we had defined a proper
behavior to, but since it causes an infinite loop, it needs to be fixed.

@fix

src/lib/evas/canvas/evas_object_textblock.c
src/tests/evas/evas_test_textblock.c

index 2352281..1325924 100644 (file)
@@ -4904,7 +4904,7 @@ _layout_par(Ctxt *c)
                }
              /* If we want to wrap and it's worth checking for wrapping
               * (i.e there's actually text). */
-             else if ((it->format->wrap_word || it->format->wrap_char ||
+             else if (((wrap > 0) || it->format->wrap_word || it->format->wrap_char ||
                 it->format->wrap_mixed) && it->text_node)
                {
                   size_t line_start;
index b52f35c..1c1d596 100644 (file)
@@ -1911,6 +1911,13 @@ START_TEST(evas_textblock_wrapping)
 
    fail_if(w > h); /* FIXME: Not the best test, should be more strict. */
 
+   evas_object_textblock_text_markup_set(tb,
+         "<wrap=none>aaa bbbbbbbbbbb ccccc</wrap><wrap=word>dddddd</wrap>");
+   evas_object_textblock_size_native_get(tb, &nw, &nh);
+   evas_object_resize(tb, nw / 2, nh * 4);
+   evas_object_textblock_size_formatted_get(tb, &w, NULL);
+   ck_assert_int_le(w, nw);
+
    END_TB_TEST();
 }
 END_TEST