video: Do not free an instance in a handler of removing E_Client. 89/247489/1
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 14 Oct 2020 04:55:48 +0000 (13:55 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Wed, 11 Nov 2020 06:25:08 +0000 (15:25 +0900)
Do not free an instance associated with tizen_video_object in a handler
of removing E_Client. The instance should be removed with wl_resource.

Change-Id: I6d3ac1ab81cc69a3b161415e84de41a20cf0520a

src/bin/video/e_comp_wl_video.c

index cbef685cd6a9b2693e91bd017011d141acd08f3c..0e340a9debda85713ce9ce2a5003122487d6e87f 100644 (file)
@@ -20,7 +20,6 @@ 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)
@@ -54,9 +53,13 @@ _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_comp_wl_video_object_destroy(vo);
+   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;
 
    return ECORE_CALLBACK_PASS_ON;
 }
@@ -129,31 +132,21 @@ _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)
-{
-   if (!vo)
-     return;
-
-   VIN("destroy", 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);
+   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);
+
+        e_client_video_unset(vo->ec);
+     }
+
+   free(vo);
 }
 
 static void
@@ -173,7 +166,6 @@ _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;
@@ -228,7 +220,6 @@ _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;
@@ -253,7 +244,6 @@ _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;
@@ -271,7 +261,6 @@ _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;
@@ -287,7 +276,6 @@ _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;