summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hirt <daniel.hirt@samsung.com>2016-06-14 15:44:37 +0000
committerDaniel Hirt <daniel.hirt@samsung.com>2016-06-14 15:51:27 +0000
commit6a638dfde59f6cc760678054f7bac2e18779b0d6 (patch)
tree5c8b0527516375be9bd02f53e4e2f502d47f2ec2
parent33c6da3ee7cc20326c93b378c5d71129b0394603 (diff)
downloadefl-6a638dfde59f6cc760678054f7bac2e18779b0d6.tar.gz
Efl.Canvas.Text: delay cursor event emit in markup_set
This is too much work for the sake of preventing code repeat. The main reason is that we sometimes use the cursor API internally, which is a problem as it may emit the cursor's 'change' event before all work is completed. Luckily, valgrind spewed out errors over this.
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 2b422bd069..d7cb24612a 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -655,6 +655,7 @@ static void _evas_textblock_cursor_at_format_set(Efl_Canvas_Text_Cursor_Data *cu
static void _evas_textblock_cursor_paragraph_char_last(Efl_Canvas_Text_Cursor_Data *cur);
static void _evas_textblock_cursor_init(Efl_Canvas_Text_Cursor_Data *cur, const Evas_Object *tb);
static int _efl_canvas_text_cursor_text_append(Efl_Canvas_Text_Cursor_Data *cur, const char *text);
+static void _cursor_paragraph_first(Efl_Canvas_Text_Cursor_Data *cur);
#ifdef HAVE_HYPHEN
/* Hyphenation */
@@ -7065,20 +7066,37 @@ evas_object_textblock_text_markup_set(Eo *eo_obj, const char *text)
EINA_INLIST_GET(o->text_nodes),
EINA_INLIST_GET(co->node)));
- evas_textblock_cursor_paragraph_first(o->cursor);
- evas_object_textblock_text_markup_prepend(o->cursor, text);
/* Point all the cursors to the starrt */
{
Eina_List *l;
Efl_Canvas_Text_Cursor *data;
+ Efl_Canvas_Text_Cursor_Data *cur;
- evas_textblock_cursor_paragraph_first(o->cursor);
+ // We are changing the cursors here, so we're going to go over them
+ // again at the end of the function to emit the 'change' event.
+ // It's important that we do that at the end of the function.
EINA_LIST_FOREACH(o->cursors, l, data)
- evas_textblock_cursor_paragraph_first(data);
- }
+ {
+ cur = eo_data_scope_get(data, EFL_CANVAS_TEXT_CURSOR_CLASS);
+ _cursor_paragraph_first(cur);
+ }
- o->markup_text = text;
+ cur = eo_data_scope_get(o->cursor, EFL_CANVAS_TEXT_CURSOR_CLASS);
+ _cursor_paragraph_first(cur);
+ evas_object_textblock_text_markup_prepend(o->cursor, text);
+ _cursor_paragraph_first(cur);
+ o->markup_text = text;
+
+ // Now, emit the events.
+ eo_event_callback_call(o->cursor,
+ EFL_CANVAS_TEXT_CURSOR_EVENT_CHANGED, NULL);
+ EINA_LIST_FOREACH(o->cursors, l, data)
+ {
+ eo_event_callback_call(data,
+ EFL_CANVAS_TEXT_CURSOR_EVENT_CHANGED, NULL);
+ }
+ }
}
EAPI void
@@ -8260,15 +8278,20 @@ found:
_evas_textblock_changed(o, eo_obj);
}
-EOLIAN static void
-_efl_canvas_text_cursor_paragraph_first(Evas_Textblock_Cursor *cur_obj, Efl_Canvas_Text_Cursor_Data *cur)
+static void
+_cursor_paragraph_first(Efl_Canvas_Text_Cursor_Data *cur)
{
Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJECT_CLASS);
evas_object_async_block(obj);
Efl_Canvas_Text_Data *o = eo_data_scope_get(cur->obj, MY_CLASS);
cur->node = o->text_nodes;
cur->pos = 0;
+}
+EOLIAN static void
+_efl_canvas_text_cursor_paragraph_first(Evas_Textblock_Cursor *cur_obj, Efl_Canvas_Text_Cursor_Data *cur)
+{
+ _cursor_paragraph_first(cur);
eo_event_callback_call(cur_obj, EFL_CANVAS_TEXT_CURSOR_EVENT_CHANGED, NULL);
}