Canvas text: fix re-add of existing style to list
authorDaniel Hirt <hirt.danny@gmail.com>
Mon, 7 Aug 2017 08:52:55 +0000 (11:52 +0300)
committerDaniel Hirt <hirt.danny@gmail.com>
Mon, 7 Aug 2017 16:36:23 +0000 (19:36 +0300)
Styles were appended regardless their key already existing.
Now it's fixed.
Also, improved readability of 'style_set'.

src/lib/evas/canvas/evas_object_textblock.c

index 91e4649..8e6df24 100644 (file)
@@ -7009,10 +7009,13 @@ _efl_canvas_text_style_set(Eo *eo_obj, Efl_Canvas_Text_Data *o, const char *key,
    ts = _style_by_key_find(o, key);
 
    if (!ts && !style)
-      return;
+     {
+        return;
+     }
 
    if (ts && !style)
      {
+        // Delete the style
         if (!key)
           {
              evas_textblock_style_set(ts, "");
@@ -7023,28 +7026,23 @@ _efl_canvas_text_style_set(Eo *eo_obj, Efl_Canvas_Text_Data *o, const char *key,
              ts->objects = eina_list_remove(ts->objects, eo_obj);
              evas_textblock_style_free(ts);
           }
-
-        goto end;
      }
-   else if (!ts)
+   else if (!ts && style)
      {
         Evas_Textblock_Style *tmp = NULL;
+
+        // No entry for respective key, so create one.
         ts = evas_textblock_style_new();
+        evas_textblock_style_set(ts, style);
+        ts->key = eina_stringshare_add(key);
+        o->styles = eina_list_append(o->styles, ts);
         _textblock_style_generic_set(eo_obj, ts, &tmp);
      }
-
-   evas_textblock_style_set(ts, style);
-
-   if (!key)
-     {
-        o->style = ts;
-     }
-   else
+   else if (ts && style)
      {
-        ts->key = eina_stringshare_add(key);
-        o->styles = eina_list_append(o->styles, ts);
+        evas_textblock_style_set(ts, style);
      }
-end:
+
    o->format_changed = EINA_TRUE;
    _evas_textblock_invalidate_all(o);
    _evas_textblock_changed(o, eo_obj);