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 698d08599b6f5657b39d5a437aac4b8246e52366..3f81442b5bfb6b0dc3ce9d98cab4d4808ea5f02f 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 9f089c8b92246884bedc9daaa59a87a94271f5b2..4093c648c56bb4dfc36d6a8cb574330a655b5b5f 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 a0a9357a43e7ac3d727549bf75d30cb5fc882668..8eb743e807525d4f4279eea37b55fa404a3bb239 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;