summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli <ali198724@gmail.com>2020-03-26 14:49:02 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2020-03-26 14:49:02 +0900
commit43ac889bc1634ec6a05e040e670b01c2ccc3fc62 (patch)
tree99148b2712b11e9bbbb6ce075e18e01cc7be7ef6
parentf6cb2340701f65c08508bc5c4988caa06141865e (diff)
evas_textblock: prevent updating cursor unless they are ready during markup_set
Summary: During Markup_set at text block level, we will not update the cursors, unless their status is updated and ready. This can cause serious issues, especially if a cursor also depends on another cursor for some calculations, (like the segfault happening in TextBox T8637) Reviewers: woohyun, bu5hm4n, zmike Reviewed By: woohyun Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8637 Differential Revision: https://phab.enlightenment.org/D11598
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c23
-rw-r--r--src/tests/elementary/efl_ui_test_text.c6
2 files changed, 23 insertions, 6 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index efd2833b67..445ce135dd 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -577,6 +577,8 @@ static void evas_object_textblock_coords_recalc(Evas_Object *eo_obj,
577 void *type_private_data); 577 void *type_private_data);
578static void _canvas_text_format_changed(Eo *eo_obj, Efl_Canvas_Textblock_Data *o); 578static void _canvas_text_format_changed(Eo *eo_obj, Efl_Canvas_Textblock_Data *o);
579 579
580static void _evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur,
581 Eina_Bool emit_change);
580static const Evas_Object_Func object_func = 582static const Evas_Object_Func object_func =
581{ 583{
582 /* methods (compulsory) */ 584 /* methods (compulsory) */
@@ -8735,10 +8737,14 @@ _evas_object_textblock_text_markup_set(Eo *eo_obj, Efl_Canvas_Textblock_Data *o,
8735 Eina_List *l; 8737 Eina_List *l;
8736 Efl_Text_Cursor_Handle *cur; 8738 Efl_Text_Cursor_Handle *cur;
8737 8739
8738 evas_textblock_cursor_paragraph_first(o->cursor); 8740 /*update all cursors positions first, without emitting change*/
8741 EINA_LIST_FOREACH(o->cursors, l, cur)
8742 {
8743 _evas_textblock_cursor_paragraph_first(cur, EINA_FALSE);
8744 }
8745 /*emitting change event for all cursors, after all of them are ready*/
8739 EINA_LIST_FOREACH(o->cursors, l, cur) 8746 EINA_LIST_FOREACH(o->cursors, l, cur)
8740 { 8747 {
8741 evas_textblock_cursor_paragraph_first(cur);
8742 _evas_textblock_cursor_object_changed(cur); 8748 _evas_textblock_cursor_object_changed(cur);
8743 } 8749 }
8744 8750
@@ -9992,8 +9998,8 @@ found:
9992 _evas_textblock_changed(o, eo_obj); 9998 _evas_textblock_changed(o, eo_obj);
9993} 9999}
9994 10000
9995EAPI void 10001static void
9996evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur) 10002_evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur, Eina_Bool emit_change)
9997{ 10003{
9998 if (!cur) return; 10004 if (!cur) return;
9999 Evas_Object_Protected_Data *obj = efl_data_scope_get(cur->obj, EFL_CANVAS_OBJECT_CLASS); 10005 Evas_Object_Protected_Data *obj = efl_data_scope_get(cur->obj, EFL_CANVAS_OBJECT_CLASS);
@@ -10001,7 +10007,14 @@ evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur)
10001 Efl_Canvas_Textblock_Data *o = efl_data_scope_get(cur->obj, MY_CLASS); 10007 Efl_Canvas_Textblock_Data *o = efl_data_scope_get(cur->obj, MY_CLASS);
10002 cur->node = o->text_nodes; 10008 cur->node = o->text_nodes;
10003 cur->pos = 0; 10009 cur->pos = 0;
10004 _evas_textblock_cursor_object_changed(cur); 10010 if (emit_change)
10011 _evas_textblock_cursor_object_changed(cur);
10012}
10013
10014EAPI void
10015evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur)
10016{
10017 _evas_textblock_cursor_paragraph_first(cur, EINA_TRUE);
10005} 10018}
10006 10019
10007EAPI void 10020EAPI void
diff --git a/src/tests/elementary/efl_ui_test_text.c b/src/tests/elementary/efl_ui_test_text.c
index 63df67919c..63df0e70f6 100644
--- a/src/tests/elementary/efl_ui_test_text.c
+++ b/src/tests/elementary/efl_ui_test_text.c
@@ -52,7 +52,7 @@ _stop_event_soon(void *data EINA_UNUSED, const Efl_Event *ev)
52 52
53EFL_START_TEST(text_all_select_all_unselect) 53EFL_START_TEST(text_all_select_all_unselect)
54{ 54{
55 Eo *txt; 55 Eo *txt, *txt2;
56 Eo *win = win_add(); 56 Eo *win = win_add();
57 57
58 int i_have_selection = 0, i_selection = 0; 58 int i_have_selection = 0, i_selection = 0;
@@ -116,8 +116,12 @@ EFL_START_TEST(text_all_select_all_unselect)
116 efl_text_interactive_all_unselect(txt); 116 efl_text_interactive_all_unselect(txt);
117 ck_assert_int_eq(i_have_selection, 2); 117 ck_assert_int_eq(i_have_selection, 2);
118 118
119 //cursor selection change on efl_markup_set
120 txt2 = efl_add(EFL_UI_TEXTBOX_CLASS, win);
121 efl_text_markup_set(txt2, "<ps>");
119 122
120 efl_del(txt); 123 efl_del(txt);
124 efl_del(txt2);
121 efl_del(win); 125 efl_del(win);
122} 126}
123EFL_END_TEST 127EFL_END_TEST