reset textblock cache when text_class is changed
authorSohyun Kim <sohyun.anna@gmail.com>
Thu, 27 Feb 2014 04:31:42 +0000 (13:31 +0900)
committerSohyun Kim <sohyun.anna@gmail.com>
Thu, 27 Feb 2014 04:31:42 +0000 (13:31 +0900)
If text_class in the textblock is changed, it is not applied because of the cache.
When text_class is changed, reset cache to update text information.

src/lib/edje/edje_private.h
src/lib/edje/edje_textblock_styles.c
src/lib/edje/edje_util.c

index 698d085..3f81442 100644 (file)
@@ -2165,6 +2165,7 @@ void          _edje_message_del             (Edje *ed);
 
 void _edje_textblock_styles_add(Edje *ed);
 void _edje_textblock_styles_del(Edje *ed);
+void _edje_textblock_styles_cache_free(Edje *ed, const char *text_class);
 void _edje_textblock_style_all_update(Edje *ed);
 void _edje_textblock_style_parse_and_fix(Edje_File *edf);
 void _edje_textblock_style_cleanup(Edje_File *edf);
index 9f089c8..4093c64 100644 (file)
@@ -310,6 +310,35 @@ _edje_textblock_styles_del(Edje *ed)
      }
 }
 
+void
+_edje_textblock_styles_cache_free(Edje *ed, const char *text_class)
+{
+   Eina_List *l, *ll;
+   Edje_Style *stl;
+
+   if (!ed->file) return;
+   if (!text_class) return;
+
+   EINA_LIST_FOREACH(ed->file->styles, l, stl)
+     {
+        Edje_Style_Tag *tag;
+        Eina_Bool found = EINA_FALSE;
+
+        EINA_LIST_FOREACH(stl->tags, ll, tag)
+          {
+             if (!tag->text_class) continue;
+
+             if (!strcmp(tag->text_class, text_class))
+               {
+                  found = EINA_TRUE;
+                  break;
+               }
+          }
+        if (found)
+          stl->cache = EINA_FALSE;
+     }
+}
+
 /* When we get to here the edje file had been read into memory
  * the name of the style is established as well as the name and
  * data for the tags.  This function will create the Evas_Style
index a0a9357..8eb743e 100644 (file)
@@ -962,6 +962,7 @@ edje_text_class_set(const char *text_class, const char *font, Evas_Font_Size siz
         ed = eina_list_data_get(members);
         ed->dirty = EINA_TRUE;
         ed->recalc_call = EINA_TRUE;
+        _edje_textblock_styles_cache_free(ed, text_class);
         _edje_textblock_style_all_update(ed);
 #ifdef EDJE_CALC_CACHE
         ed->text_part_change = EINA_TRUE;
@@ -995,6 +996,7 @@ edje_text_class_del(const char *text_class)
 
         ed = eina_list_data_get(members);
         ed->dirty = EINA_TRUE;
+        _edje_textblock_styles_cache_free(ed, text_class);
         _edje_textblock_style_all_update(ed);
 #ifdef EDJE_CALC_CACHE
         ed->text_part_change = EINA_TRUE;
@@ -1107,6 +1109,7 @@ _text_class_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
 #ifdef EDJE_CALC_CACHE
    ed->text_part_change = EINA_TRUE;
 #endif
+   _edje_textblock_styles_cache_free(ed, text_class);
    _edje_textblock_style_all_update(ed);
    _edje_recalc(ed);
    if (ret) *ret = EINA_TRUE;