Evas textblock: Better handle visible formats.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 9 Feb 2012 12:21:18 +0000 (12:21 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 9 Feb 2012 12:21:18 +0000 (12:21 +0000)
Fixed a crash. Thanks WooHyun for making me fix it now. :)

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@67790 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

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

index 07ef62f..6008d74 100644 (file)
@@ -5690,7 +5690,6 @@ EAPI Eina_Bool
 evas_textblock_cursor_is_format(const Evas_Textblock_Cursor *cur)
 {
    if (!cur || !cur->node) return EINA_FALSE;
-   if (evas_textblock_cursor_format_is_visible_get(cur)) return EINA_TRUE;
    return (_evas_textblock_cursor_node_format_at_pos_get(cur)) ?
       EINA_TRUE : EINA_FALSE;
 }
@@ -8068,6 +8067,7 @@ evas_textblock_cursor_format_is_visible_get(const Evas_Textblock_Cursor *cur)
 
    if (!cur) return EINA_FALSE;
    if (!cur->node) return EINA_FALSE;
+   if (!evas_textblock_cursor_is_format(cur)) return EINA_FALSE;
    text = eina_ustrbuf_string_get(cur->node->unicode);
    return EVAS_TEXTBLOCK_IS_VISIBLE_FORMAT_CHAR(text[cur->pos]);
 }
index 7413f70..88c4ac8 100644 (file)
@@ -1283,6 +1283,15 @@ START_TEST(evas_textblock_various)
    evas_object_textblock_text_markup_set(tb, "a<ps/>a<ps/>a");
    fail_if(!_evas_textblock_check_item_node_link(tb));
 
+   /* These shouldn't crash (although the desired outcome is not yet defined) */
+   evas_object_textblock_text_markup_set(tb, "&#xfffc;");
+   evas_textblock_cursor_pos_set(cur, 0);
+   evas_textblock_cursor_char_delete(cur);
+
+   evas_object_textblock_text_markup_set(tb, "\xEF\xBF\xBC");
+   evas_textblock_cursor_pos_set(cur, 0);
+   evas_textblock_cursor_char_delete(cur);
+
    END_TB_TEST();
 }
 END_TEST