aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-09-01 15:21:22 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-09-13 09:57:05 +0900
commite380dae4bc927f9710fa89c2831ebfa733b0e013 (patch)
tree496d9f6e8f8d1482dd18082589abca532684ac02
parentevas: Remove private data for clipped object (diff)
downloadefl-e380dae4bc927f9710fa89c2831ebfa733b0e013.tar.gz
evas: Remove group_del override from smart clipped
-rw-r--r--src/lib/edje/edje_smart.c1
-rw-r--r--src/lib/evas/canvas/evas_object_box.c1
-rw-r--r--src/lib/evas/canvas/evas_object_smart.c44
-rw-r--r--src/lib/evas/canvas/evas_object_smart_clipped.c25
4 files changed, 41 insertions, 30 deletions
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index 85c4a5530b..136f2d1249 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -148,7 +148,6 @@ _edje_object_efl_canvas_group_group_del(Eo *obj, Edje *ed)
_edje_block_violate(ed);
ed->delete_me = 1;
_edje_edjes = eina_inlist_remove(_edje_edjes, EINA_INLIST_GET(ed));
- evas_object_smart_data_set(obj, NULL);
if (_edje_lua_script_only(ed)) _edje_lua_script_only_shutdown(ed);
#ifdef HAVE_EPHYSICS
/* clear physics world / shutdown ephysics */
diff --git a/src/lib/evas/canvas/evas_object_box.c b/src/lib/evas/canvas/evas_object_box.c
index b7e021886b..8e053bc4cc 100644
--- a/src/lib/evas/canvas/evas_object_box.c
+++ b/src/lib/evas/canvas/evas_object_box.c
@@ -408,7 +408,6 @@ _evas_box_efl_canvas_group_group_add(Eo *eo_obj, Evas_Object_Box_Data *priv)
cso = evas_object_smart_data_get(eo_obj);
priv->base = *cso;
evas_object_smart_data_set(eo_obj, priv);
- free(cso);
}
EOLIAN static void
diff --git a/src/lib/evas/canvas/evas_object_smart.c b/src/lib/evas/canvas/evas_object_smart.c
index c82bd47e18..e94f788606 100644
--- a/src/lib/evas/canvas/evas_object_smart.c
+++ b/src/lib/evas/canvas/evas_object_smart.c
@@ -49,6 +49,7 @@ struct _Evas_Smart_Data
Eina_Bool update_boundingbox_needed : 1;
Eina_Bool group_del_called : 1;
Eina_Bool unclipped : 1; /* If true, NOT a smart_clipped object */
+ Eina_Bool data_nofree : 1; /* If true, do NOT free the data */
};
typedef struct
@@ -130,7 +131,13 @@ EAPI void
evas_object_smart_data_set(Evas_Object *eo_obj, void *data)
{
EVAS_OBJECT_SMART_GET_OR_RETURN(eo_obj);
- o->data = data;
+ if (o->data != data)
+ {
+ if (o->data && !o->data_nofree)
+ free(o->data);
+ o->data = data;
+ o->data_nofree = EINA_TRUE;
+ }
}
EAPI void *
@@ -517,19 +524,23 @@ evas_object_smart_members_get_direct(const Evas_Object *eo_obj)
return o->contained;
}
-void
-_efl_canvas_group_group_members_all_del(Evas_Object *eo_obj)
-{
- Evas_Smart_Data *o = efl_data_scope_get(eo_obj, MY_CLASS);
+static void
+_efl_canvas_group_group_members_all_del_internal(Evas_Smart_Data *o)
+{;
Evas_Object_Protected_Data *memobj;
Eina_Inlist *itrn;
EINA_INLIST_FOREACH_SAFE(o->contained, itrn, memobj)
- {
- evas_object_del((Evas_Object *)((Evas_Object_Protected_Data *)memobj->object));
- }
+ efl_del(memobj->object);
o->group_del_called = EINA_TRUE;
}
+void
+_efl_canvas_group_group_members_all_del(Evas_Object *eo_obj)
+{
+ Evas_Smart_Data *o = efl_data_scope_get(eo_obj, MY_CLASS);
+ _efl_canvas_group_group_members_all_del_internal(o);
+}
+
static void
_evas_smart_class_ifaces_private_data_alloc(Evas_Object *eo_obj,
Evas_Smart *s)
@@ -630,6 +641,8 @@ EOLIAN static void
_efl_canvas_group_efl_object_destructor(Eo *eo_obj, Evas_Smart_Data *o)
{
efl_destructor(efl_super(eo_obj, MY_CLASS));
+ if (o->data && !o->data_nofree)
+ free(o->data);
if (!o->group_del_called)
{
ERR("efl_canvas_group_del() was not called on this object: %p (%s)",
@@ -709,8 +722,21 @@ _efl_canvas_group_group_add(Eo *eo_obj, Evas_Smart_Data *o EINA_UNUSED)
}
EOLIAN static void
-_efl_canvas_group_group_del(Eo *eo_obj EINA_UNUSED, Evas_Smart_Data *o EINA_UNUSED)
+_efl_canvas_group_group_del(Eo *eo_obj EINA_UNUSED, Evas_Smart_Data *o)
{
+ if (!o->unclipped)
+ {
+ Evas_Object_Smart_Clipped_Data *cso = o->data;
+ Eo *clipper;
+
+ if (cso && cso->clipper)
+ {
+ clipper = cso->clipper;
+ cso->clipper = NULL;
+ efl_del(clipper);
+ }
+ _efl_canvas_group_group_members_all_del_internal(o);
+ }
o->group_del_called = EINA_TRUE;
}
diff --git a/src/lib/evas/canvas/evas_object_smart_clipped.c b/src/lib/evas/canvas/evas_object_smart_clipped.c
index 50fb1b0ec3..48e576ea7a 100644
--- a/src/lib/evas/canvas/evas_object_smart_clipped.c
+++ b/src/lib/evas/canvas/evas_object_smart_clipped.c
@@ -22,7 +22,7 @@ evas_object_smart_clipped_clipper_get(const Evas_Object *eo_obj)
}
static void
-evas_object_smart_clipped_smart_add(Evas_Object *eo_obj, Evas_Object_Smart_Clipped_Data *cso)
+evas_object_smart_clipped_init(Evas_Object *eo_obj, Evas_Object_Smart_Clipped_Data *cso)
{
Evas_Object *clipper;
@@ -48,7 +48,7 @@ evas_object_smart_clipped_smart_add_legacy(Evas_Object *eo_obj)
Evas_Object_Smart_Clipped_Data *cso;
cso = calloc(1, sizeof(*cso));
- evas_object_smart_clipped_smart_add(eo_obj, cso);
+ evas_object_smart_clipped_init(eo_obj, cso);
}
EOLIAN static void
@@ -57,11 +57,11 @@ _efl_canvas_group_clipped_efl_canvas_group_group_add(Eo *eo_obj, void *_pd EINA_
Evas_Object_Smart_Clipped_Data *cso;
cso = evas_object_smart_data_get(eo_obj);
- evas_object_smart_clipped_smart_add(eo_obj, cso);
+ evas_object_smart_clipped_init(eo_obj, cso);
}
static void
-evas_object_smart_clipped_smart_del(Evas_Object *eo_obj)
+evas_object_smart_clipped_smart_del_legacy(Evas_Object *eo_obj)
{
CSO_DATA_GET_OR_RETURN(eo_obj, cso);
@@ -73,19 +73,6 @@ evas_object_smart_clipped_smart_del(Evas_Object *eo_obj)
}
_efl_canvas_group_group_members_all_del(eo_obj);
-
- /* If it's a legacy smart object, we should free the cso. */
- if (!efl_isa(eo_obj, MY_CLASS))
- free(cso);
-
- evas_object_smart_data_set(eo_obj, NULL);
-}
-
-EOLIAN static void
-_efl_canvas_group_clipped_efl_canvas_group_group_del(Eo *eo_obj, void *_pd EINA_UNUSED)
-{
- evas_object_smart_clipped_smart_del(eo_obj);
- // group_del_called was already set to true, no need to call super here.
}
static void
@@ -232,7 +219,7 @@ evas_object_smart_clipped_smart_set(Evas_Smart_Class *sc)
return;
sc->add = evas_object_smart_clipped_smart_add_legacy;
- sc->del = evas_object_smart_clipped_smart_del;
+ sc->del = evas_object_smart_clipped_smart_del_legacy;
sc->move = evas_object_smart_clipped_smart_move;
sc->show = evas_object_smart_clipped_smart_show;
sc->hide = evas_object_smart_clipped_smart_hide;
@@ -261,7 +248,7 @@ evas_object_smart_clipped_class_get(void)
/* Internal EO APIs and hidden overrides */
#define EFL_CANVAS_GROUP_CLIPPED_EXTRA_OPS \
- EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_canvas_group_clipped)
+ EFL_CANVAS_GROUP_ADD_OPS(efl_canvas_group_clipped)
#include "canvas/efl_canvas_group_clipped.eo.c"