video_shell: Destroy all resources on display destroy 51/316751/1
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 26 Aug 2024 06:11:13 +0000 (15:11 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Tue, 27 Aug 2024 23:09:37 +0000 (08:09 +0900)
There is no point in retaining video shell resources on display destroy.
With this, we don't need to use e_object anymore.

Change-Id: I0bbd6657ea9767946aa8a07cf2058da48df2a6c3

src/bin/server/e_video_shell.c

index 7a38bfd..d3d8531 100644 (file)
@@ -1,6 +1,5 @@
 #include "e_types.h"
 #include "e_log.h"
-#include "e_object.h"
 #include "e_comp_wl.h"
 #include "e_comp_wl_intern.h"
 #include "e_client_intern.h"
@@ -46,7 +45,6 @@ typedef struct _E_Video_Viewport_Source E_Video_Viewport_Source;
 
 typedef struct
 {
-   E_Object e_obj_inherit;
    struct wl_display *display;
    struct wl_global *global;
    Eina_Hash *viewports;
@@ -359,7 +357,6 @@ _viewport_destroy(E_Video_Viewport *viewport)
      }
 
    eina_hash_del_by_data(viewport->shell->viewports, viewport);
-   e_object_unref(E_OBJECT(viewport->shell));
 
    _viewport_border_finish(viewport);
    wl_resource_set_user_data(viewport->resource, NULL);
@@ -660,7 +657,6 @@ _video_shell_cb_export_viewport(struct wl_client *client, struct wl_resource *re
    e_surface_unmap_listener_add(parent_surface, &viewport->parent_unmap);
 
    viewport->shell = wl_resource_get_user_data(resource);
-   e_object_ref(E_OBJECT(viewport->shell));
 
    _viewport_export_handle_generate(viewport);
    _viewport_name_init(viewport);
@@ -1620,7 +1616,6 @@ _video_surface_destroy(E_Video_Surface *surface)
    if (surface->subsurface)
      wl_list_remove(&surface->subsurface_destroy.link);
 
-   e_object_unref(E_OBJECT(surface->shell));
    wl_resource_set_user_data(surface->resource, NULL);
    wl_list_remove(&surface->surface_destroy.link);
    free(surface->name);
@@ -1677,7 +1672,6 @@ _video_shell_cb_get_surface(struct wl_client *client, struct wl_resource *resour
 
    surface->role = E_VIDEO_SURFACE_ROLE_NONE;
    surface->shell = wl_resource_get_user_data(resource);
-   e_object_ref(E_OBJECT(surface->shell));
 
    surface->surface = e_surface;
    surface->surface_destroy.notify = _video_surface_cb_surface_destroy;
@@ -1730,20 +1724,23 @@ static void
 _video_shell_cb_display_destroy(struct wl_listener *listener, void *data)
 {
    E_Video_Shell *shell = wl_container_of(listener, shell, display_destroy);
+   E_Video_Viewport *viewport;
+   Eina_Iterator *itr;
 
    VS_INF("SHELL %p| wl_display destroyed", shell);
 
-   wl_list_remove(&shell->display_destroy.link);
-   wl_global_destroy(shell->global);
-   e_object_del(E_OBJECT(shell));
-}
-
-static void
-_video_shell_free(E_Video_Shell *shell)
-{
-   VS_INF("SHELL %p| Free", shell);
+   itr = eina_hash_iterator_data_new(shell->viewports);
+   EINA_ITERATOR_FOREACH(itr, viewport)
+     {
+        if (viewport->source)
+          _video_surface_destroy(viewport->source->surface);
+        _viewport_destroy(viewport);
+     }
+   eina_iterator_free(itr);
 
    eina_hash_free(shell->viewports);
+   wl_global_destroy(shell->global);
+   wl_list_remove(&shell->display_destroy.link);
    wl_list_remove(&shell->link);
    free(shell);
 }
@@ -1753,7 +1750,7 @@ e_video_shell_create(struct wl_display *display)
 {
    E_Video_Shell *shell;
 
-   shell = E_OBJECT_ALLOC(E_Video_Shell, E_VIDEO_SHELL_TYPE, _video_shell_free);
+   shell = E_NEW(E_Video_Shell, 1);
    if (!shell)
      return NULL;