evas: Override del() for evas objects
authorJean-Philippe Andre <jp.andre@samsung.com>
Thu, 28 Sep 2017 09:03:33 +0000 (18:03 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 10 Oct 2017 09:44:35 +0000 (18:44 +0900)
This makes EAPI evas_object_del() and EO API efl_del() work the same on
evas objects, i.e. a del() implies an immediate call to hide() and mark
the object as "delete_me".

If the refcount remains > 0 the object won't be actually deleted, thus
EFL_EVENT_DEL won't be triggered. I think it would probably be a good
idea to have a new event "del,request", to signal reference owners that
this object "wants" to die.

Ping @raster @zmike

src/lib/evas/canvas/efl_canvas_object.eo
src/lib/evas/canvas/evas_object_main.c

index 61c5949..ac3ecd4 100644 (file)
@@ -662,6 +662,7 @@ abstract Efl.Canvas.Object (Efl.Object, Efl.Gfx, Efl.Gfx.Stack, Efl.Animator,
       Efl.Object.destructor;
       Efl.Object.finalize;
       Efl.Object.provider_find;
+      Efl.Object.del;
       Efl.Object.debug_name_override;
       Efl.Gfx.visible { get; set; }
       Efl.Gfx.color { get; set; }
index d298efb..e6f36ec 100644 (file)
@@ -902,17 +902,9 @@ evas_object_ref_get(const Evas_Object *eo_obj)
    return obj->ref;
 }
 
-EAPI void
-evas_object_del(Evas_Object *eo_obj)
+EOLIAN static void
+_efl_canvas_object_efl_object_del(const Eo *eo_obj, Evas_Object_Protected_Data *obj)
 {
-   if (!eo_obj) return;
-   MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
-   return;
-   MAGIC_CHECK_END();
-
-   Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, MY_CLASS);
-
-   if (!obj) return;
    evas_object_async_block(obj);
    if (obj->delete_me || obj->efl_del_called) return;
    if (obj->ref > 0)
@@ -920,9 +912,21 @@ evas_object_del(Evas_Object *eo_obj)
         obj->del_ref = EINA_TRUE;
         return;
      }
-   evas_object_hide(eo_obj);
+   efl_gfx_visible_set((Eo *) eo_obj, EINA_FALSE);
    obj->efl_del_called = EINA_TRUE;
+   efl_del(efl_super(eo_obj, MY_CLASS));
+}
 
+EAPI void
+evas_object_del(Evas_Object *eo_obj)
+{
+   if (!eo_obj) return;
+   if (!efl_isa(eo_obj, MY_CLASS))
+     {
+        ERR("Called %s on a non-evas object: %s@%p",
+            __FUNCTION__, efl_class_name_get(eo_obj), eo_obj);
+        return;
+     }
    efl_del(eo_obj);
 }