Revert "video: Do not free an instance in a handler of removing E_Client." 46/246846/1
authorDoyoun Kang <doyoun.kang@samsung.com>
Wed, 4 Nov 2020 11:54:02 +0000 (20:54 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Wed, 4 Nov 2020 11:54:09 +0000 (20:54 +0900)
This reverts commit 2c80683703923f54749a81f410cea50f4d772a3b.

Change-Id: Ic2d4371635a9e4019e9390aae297c113eb08c90c

src/bin/video/e_comp_wl_video.c

index 0e340a9debda85713ce9ce2a5003122487d6e87f..cbef685cd6a9b2693e91bd017011d141acd08f3c 100644 (file)
@@ -20,6 +20,7 @@ struct _E_Video_Object
 };
 
 static void _e_comp_wl_video_object_setup(E_Video_Object *vo, E_Client *ec);
+static void _e_comp_wl_video_object_destroy(E_Video_Object *vo);
 
 static int
 _e_comp_wl_video_object_prop_id_get(E_Video_Object *vo, const char *name)
@@ -53,13 +54,9 @@ _e_comp_wl_video_object_ec_cb_remove(void *data, int type, void *event)
    ec = ev->ec;
    vo = data;
    if (vo->ec != ec) return ECORE_CALLBACK_PASS_ON;
+   if (!ec->comp_data) return ECORE_CALLBACK_PASS_ON;
 
-   E_FREE_FUNC(vo->client_event_handler.visibility_change, ecore_event_handler_del);
-   E_FREE_FUNC(vo->client_event_handler.remove, ecore_event_handler_del);
-
-   e_client_video_unset(vo->ec);
-
-   vo->ec = NULL;
+   _e_comp_wl_video_object_destroy(vo);
 
    return ECORE_CALLBACK_PASS_ON;
 }
@@ -133,22 +130,32 @@ _e_comp_wl_video_object_setup(E_Video_Object *vo, E_Client *ec)
 }
 
 static void
-_e_comp_wl_video_object_resource_destroy(struct wl_resource *resource)
+_e_comp_wl_video_object_destroy(E_Video_Object *vo)
 {
-   E_Video_Object *vo = wl_resource_get_user_data(resource);
-   EINA_SAFETY_ON_NULL_RETURN(vo);
+   if (!vo)
+     return;
 
-   if (vo->ec)
-     {
-        E_FREE_FUNC(vo->client_event_handler.visibility_change, ecore_event_handler_del);
-        E_FREE_FUNC(vo->client_event_handler.remove, ecore_event_handler_del);
+   VIN("destroy", vo->ec);
 
-        e_client_video_unset(vo->ec);
-     }
+   wl_resource_set_destructor(vo->resource, NULL);
+
+   E_FREE_FUNC(vo->client_event_handler.visibility_change, ecore_event_handler_del);
+   E_FREE_FUNC(vo->client_event_handler.remove, ecore_event_handler_del);
+
+   e_client_video_unset(vo->ec);
 
    free(vo);
 }
 
+static void
+_e_comp_wl_video_object_resource_destroy(struct wl_resource *resource)
+{
+   E_Video_Object *vo = wl_resource_get_user_data(resource);
+   EINA_SAFETY_ON_NULL_RETURN(vo);
+
+   _e_comp_wl_video_object_destroy(vo);
+}
+
 static void
 _e_comp_wl_video_object_handle_destroy(struct wl_client *client, struct wl_resource *resource)
 {
@@ -166,6 +173,7 @@ _e_comp_wl_video_object_handle_attribute_set(struct wl_client *client,
    int id;
 
    vo = wl_resource_get_user_data(resource);
+   EINA_SAFETY_ON_NULL_RETURN(vo);
 
    if (!vo->ec)
      return;
@@ -220,6 +228,7 @@ _e_comp_wl_video_object_handle_topmost_visibility_follow(struct wl_client *clien
    E_Video_Object *vo;
 
    vo = wl_resource_get_user_data(resource);
+   EINA_SAFETY_ON_NULL_RETURN(vo);
 
    if(!vo->ec)
      return;
@@ -244,6 +253,7 @@ _e_comp_wl_video_object_handle_topmost_visibility_unfollow(struct wl_client *cli
    E_Video_Object *vo;
 
    vo = wl_resource_get_user_data(resource);
+   EINA_SAFETY_ON_NULL_RETURN(vo);
 
    if(!vo->ec)
      return;
@@ -261,6 +271,7 @@ _e_comp_wl_video_object_handle_attribute_allowed(struct wl_client *client,
    E_Video_Object *vo;
 
    vo = wl_resource_get_user_data(resource);
+   EINA_SAFETY_ON_NULL_RETURN(vo);
 
    if(!vo->ec)
      return;
@@ -276,6 +287,7 @@ _e_comp_wl_video_object_handle_attribute_disallowed(struct wl_client *client,
    E_Video_Object *vo;
 
    vo = wl_resource_get_user_data(resource);
+   EINA_SAFETY_ON_NULL_RETURN(vo);
 
    if(!vo->ec)
      return;