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)
downloadefl-43ac889bc1634ec6a05e040e670b01c2ccc3fc62.tar.gz
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,
void *type_private_data);
static void _canvas_text_format_changed(Eo *eo_obj, Efl_Canvas_Textblock_Data *o);
+static void _evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur,
+ Eina_Bool emit_change);
static const Evas_Object_Func object_func =
{
/* methods (compulsory) */
@@ -8735,10 +8737,14 @@ _evas_object_textblock_text_markup_set(Eo *eo_obj, Efl_Canvas_Textblock_Data *o,
Eina_List *l;
Efl_Text_Cursor_Handle *cur;
- evas_textblock_cursor_paragraph_first(o->cursor);
+ /*update all cursors positions first, without emitting change*/
+ EINA_LIST_FOREACH(o->cursors, l, cur)
+ {
+ _evas_textblock_cursor_paragraph_first(cur, EINA_FALSE);
+ }
+ /*emitting change event for all cursors, after all of them are ready*/
EINA_LIST_FOREACH(o->cursors, l, cur)
{
- evas_textblock_cursor_paragraph_first(cur);
_evas_textblock_cursor_object_changed(cur);
}
@@ -9992,8 +9998,8 @@ found:
_evas_textblock_changed(o, eo_obj);
}
-EAPI void
-evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur)
+static void
+_evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur, Eina_Bool emit_change)
{
if (!cur) return;
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)
Efl_Canvas_Textblock_Data *o = efl_data_scope_get(cur->obj, MY_CLASS);
cur->node = o->text_nodes;
cur->pos = 0;
- _evas_textblock_cursor_object_changed(cur);
+ if (emit_change)
+ _evas_textblock_cursor_object_changed(cur);
+}
+
+EAPI void
+evas_textblock_cursor_paragraph_first(Efl_Text_Cursor_Handle *cur)
+{
+ _evas_textblock_cursor_paragraph_first(cur, EINA_TRUE);
}
EAPI 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)
EFL_START_TEST(text_all_select_all_unselect)
{
- Eo *txt;
+ Eo *txt, *txt2;
Eo *win = win_add();
int i_have_selection = 0, i_selection = 0;
@@ -116,8 +116,12 @@ EFL_START_TEST(text_all_select_all_unselect)
efl_text_interactive_all_unselect(txt);
ck_assert_int_eq(i_have_selection, 2);
+ //cursor selection change on efl_markup_set
+ txt2 = efl_add(EFL_UI_TEXTBOX_CLASS, win);
+ efl_text_markup_set(txt2, "<ps>");
efl_del(txt);
+ efl_del(txt2);
efl_del(win);
}
EFL_END_TEST