forked from enlightenment/efl
evas textblock: manage default style properly for new interfaces
Summary: Calling efl_canvas_text_style_set() with empty key means setting a default style to object. But, it counldn't store style as default properly. It caused a crash issue from elementary_test. @fix Test Plan: New test case is included. Run test suite. Or, 1. Run elementary_test 2. Find and launch "Image Zoomable animation" test. 3. Close the image test window. 4. See the crash issue. Reviewers: raster, herdsman, jpeg, cedric, zmike Subscribers: zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D5692 Committer's note: rebased and removed unrelated test.
This commit is contained in:
parent
f437a3075a
commit
f17cae08e6
|
@ -7295,7 +7295,14 @@ _efl_canvas_text_style_set(Eo *eo_obj, Efl_Canvas_Text_Data *o, const char *key,
|
||||||
ts = evas_textblock_style_new();
|
ts = evas_textblock_style_new();
|
||||||
evas_textblock_style_set(ts, style);
|
evas_textblock_style_set(ts, style);
|
||||||
ts->key = eina_stringshare_add(key);
|
ts->key = eina_stringshare_add(key);
|
||||||
o->styles = eina_list_append(o->styles, ts);
|
|
||||||
|
/* If the given key value is NULL, newly created Evas Textblock Style
|
||||||
|
* has to be assigned to o->style. */
|
||||||
|
if (ts->key)
|
||||||
|
o->styles = eina_list_append(o->styles, ts);
|
||||||
|
else
|
||||||
|
o->style = ts;
|
||||||
|
|
||||||
_textblock_style_generic_set(eo_obj, ts, &tmp);
|
_textblock_style_generic_set(eo_obj, ts, &tmp);
|
||||||
}
|
}
|
||||||
else if (ts && style)
|
else if (ts && style)
|
||||||
|
|
|
@ -4480,6 +4480,48 @@ EFL_START_TEST(evas_textblock_annotation)
|
||||||
}
|
}
|
||||||
EFL_END_TEST;
|
EFL_END_TEST;
|
||||||
|
|
||||||
|
#define START_EFL_CANVAS_TEXT_TEST() \
|
||||||
|
Evas *evas; \
|
||||||
|
Eo *txt; \
|
||||||
|
Efl_Text_Cursor_Cursor *cur; \
|
||||||
|
evas = EVAS_TEST_INIT_EVAS(); \
|
||||||
|
evas_font_hinting_set(evas, EVAS_FONT_HINTING_AUTO); \
|
||||||
|
txt = efl_add(EFL_CANVAS_TEXT_CLASS, evas); \
|
||||||
|
fail_if(!txt); \
|
||||||
|
efl_canvas_text_legacy_newline_set(txt, EINA_FALSE); \
|
||||||
|
efl_canvas_text_style_set(txt, NULL, style_buf); \
|
||||||
|
fail_if(!efl_canvas_text_style_get(txt, NULL) || \
|
||||||
|
strcmp(style_buf, efl_canvas_text_style_get(txt, NULL))); \
|
||||||
|
cur = efl_text_cursor_new(txt); \
|
||||||
|
fail_if(!cur); \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
|
#define END_EFL_CANVAS_TEXT_TEST() \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
efl_text_cursor_free(txt, cur); \
|
||||||
|
efl_del(txt); \
|
||||||
|
evas_free(evas); \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
|
EFL_START_TEST(efl_canvas_text_simple)
|
||||||
|
{
|
||||||
|
START_EFL_CANVAS_TEXT_TEST();
|
||||||
|
|
||||||
|
/* It is simple test for Efl_Canvas_Text.
|
||||||
|
* The main object is "txt". */
|
||||||
|
const char *buf = "Th<i>i</i>s is a <br/> te<b>s</b>t.";
|
||||||
|
efl_text_set(txt, buf);
|
||||||
|
fail_if(strcmp(efl_text_get(txt), buf));
|
||||||
|
|
||||||
|
END_EFL_CANVAS_TEXT_TEST();
|
||||||
|
}
|
||||||
|
EFL_END_TEST
|
||||||
|
|
||||||
EFL_START_TEST(efl_canvas_text_cursor)
|
EFL_START_TEST(efl_canvas_text_cursor)
|
||||||
{
|
{
|
||||||
START_TB_TEST();
|
START_TB_TEST();
|
||||||
|
@ -4541,6 +4583,7 @@ void evas_test_textblock(TCase *tc)
|
||||||
#endif
|
#endif
|
||||||
tcase_add_test(tc, evas_textblock_text_iface);
|
tcase_add_test(tc, evas_textblock_text_iface);
|
||||||
tcase_add_test(tc, evas_textblock_annotation);
|
tcase_add_test(tc, evas_textblock_annotation);
|
||||||
|
tcase_add_test(tc, efl_canvas_text_simple);
|
||||||
tcase_add_test(tc, efl_canvas_text_cursor);
|
tcase_add_test(tc, efl_canvas_text_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue