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
This commit is contained in:
Ali Alzyod 2020-03-26 14:49:02 +09:00 committed by WooHyun Jung
parent f6cb234070
commit 43ac889bc1
2 changed files with 23 additions and 6 deletions

View File

@ -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

View File

@ -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