Evas filters: Fix COW usage.
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 29 Oct 2014 06:10:03 +0000 (15:10 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 29 Oct 2014 06:12:53 +0000 (15:12 +0900)
Thanks cedric for the report.
We'll need a new function (after 1.12) to detect if the current
cow pointer is the default data or not. Maybe eina_cow_default_get()
or maybe something just returning a bool.

src/lib/evas/canvas/evas_object_main.c
src/lib/evas/canvas/evas_object_text.c
src/lib/evas/include/evas_private.h

index fded1ce..ac1f53e 100644 (file)
@@ -35,6 +35,7 @@ static const Evas_Object_Protected_State default_state = {
 static const Evas_Object_Filter_Data default_filter = {
   NULL, NULL, NULL, NULL, EINA_FALSE, EINA_FALSE
 };
+const void * const evas_object_filter_cow_default = &default_filter;
 
 Eina_Cow *evas_object_proxy_cow = NULL;
 Eina_Cow *evas_object_map_cow = NULL;
index 3cf8df3..8eadf07 100644 (file)
@@ -403,7 +403,8 @@ _evas_text_efl_text_properties_font_source_get(Eo *eo_obj EINA_UNUSED, Evas_Text
 static inline void
 _evas_text_filter_changed_set(Evas_Text_Data *o, Eina_Bool val)
 {
-   if (o->cur.filter && (o->cur.filter->changed != val))
+   if ((evas_object_filter_cow_default != o->cur.filter)
+       && (o->cur.filter->changed != val))
      {
         EINA_COW_WRITE_BEGIN(evas_object_filter_cow, o->cur.filter, Evas_Object_Filter_Data, fcow)
           fcow->changed = val;
@@ -1542,17 +1543,21 @@ evas_object_text_free(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj)
    Evas_Text_Data *o = eo_data_scope_get(eo_obj, MY_CLASS);
 
    /* free filter output */
-   EINA_COW_WRITE_BEGIN(evas_object_filter_cow, o->cur.filter, Evas_Object_Filter_Data, fcow)
-     if (fcow->output)
-       ENFN->image_free(ENDT, fcow->output);
-     eina_hash_free(fcow->sources);
-     evas_filter_program_del(fcow->chain);
-     eina_stringshare_del(fcow->code);
-     fcow->output = NULL;
-     fcow->chain = NULL;
-     fcow->sources = NULL;
-     fcow->code = NULL;
-   EINA_COW_WRITE_END(evas_object_filter_cow, o->cur.filter, fcow);
+   if (evas_object_filter_cow_default != o->cur.filter)
+     {
+        EINA_COW_WRITE_BEGIN(evas_object_filter_cow, o->cur.filter, Evas_Object_Filter_Data, fcow)
+          if (fcow->output)
+            ENFN->image_free(ENDT, fcow->output);
+          eina_hash_free(fcow->sources);
+          evas_filter_program_del(fcow->chain);
+          eina_stringshare_del(fcow->code);
+          fcow->output = NULL;
+          fcow->chain = NULL;
+          fcow->sources = NULL;
+          fcow->code = NULL;
+        EINA_COW_WRITE_END(evas_object_filter_cow, o->cur.filter, fcow);
+        eina_cow_free(evas_object_filter_cow, (const Eina_Cow_Data **) &o->cur.filter);
+     }
 
    /* free obj */
    _evas_object_text_items_clear(o);
index eff901b..fd37c29 100644 (file)
@@ -1715,6 +1715,8 @@ extern Eina_Cow *evas_object_image_load_opts_cow;
 extern Eina_Cow *evas_object_image_state_cow;
 
 extern Eina_Cow *evas_object_filter_cow;
+// This should be replaced by something like "eina_cow_default_get()" maybe
+extern const void * const evas_object_filter_cow_default;
 
 # define EINA_COW_STATE_WRITE_BEGIN(Obj, Write, State)          \
   EINA_COW_WRITE_BEGIN(evas_object_state_cow, Obj->State, \