[PATCH 05/13] ivi-shell: make ivi_layout_surface destruction explicit

Nobuhiko Tanibata nobuhiko_tanibata at xddp.denso.co.jp
Sun Jun 21 23:30:53 PDT 2015


From: Nobuhiko Tanibata <NOBUHIKO_TANIBATA at xddp.denso.co.jp>

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA at xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 ivi-shell/ivi-layout-private.h |  3 ++-
 ivi-shell/ivi-layout.c         | 54 ++++++++++++------------------------------
 ivi-shell/ivi-shell.c          | 26 +++++++++++++-------
 3 files changed, 35 insertions(+), 48 deletions(-)

diff --git a/ivi-shell/ivi-layout-private.h b/ivi-shell/ivi-layout-private.h
index 9cbaa8a..8b61963 100644
--- a/ivi-shell/ivi-layout-private.h
+++ b/ivi-shell/ivi-layout-private.h
@@ -39,7 +39,6 @@ struct ivi_layout_surface {
 	struct ivi_layout *layout;
 	struct weston_surface *surface;
 
-	struct wl_listener surface_destroy_listener;
 	struct weston_transform surface_rotation;
 	struct weston_transform layer_rotation;
 	struct weston_transform surface_pos;
@@ -226,4 +225,6 @@ ivi_layout_transition_move_layer_cancel(struct ivi_layout_layer *layer);
 int
 load_controller_modules(struct weston_compositor *compositor, const char *modules,
 			int *argc, char *argv[]);
+void
+ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf);
 #endif
diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
index 2cce2d3..079b3e3 100644
--- a/ivi-shell/ivi-layout.c
+++ b/ivi-shell/ivi-layout.c
@@ -320,28 +320,27 @@ ivi_layout_surface_remove_notification(struct ivi_layout_surface *ivisurf)
 }
 
 /**
- * this shall not be called from controller because this is triggered by ivi_surface.destroy
- * This means that this is called from westonsurface_destroy_from_ivisurface.
+ * Called at destruction of wl_surface/ivi_surface
  */
-static void
-ivi_layout_surface_remove(struct ivi_layout_surface *ivisurf)
+void
+ivi_layout_surface_destroy(struct ivi_layout_surface *ivisurf)
 {
 	struct ivi_layout *layout = get_instance();
 
 	if (ivisurf == NULL) {
-		weston_log("ivi_layout_surface_remove: invalid argument\n");
+		weston_log("%s: invalid argument\n", __func__);
 		return;
 	}
 
-	if (!wl_list_empty(&ivisurf->pending.link)) {
-		wl_list_remove(&ivisurf->pending.link);
-	}
-	if (!wl_list_empty(&ivisurf->order.link)) {
-		wl_list_remove(&ivisurf->order.link);
-	}
-	if (!wl_list_empty(&ivisurf->link)) {
-		wl_list_remove(&ivisurf->link);
-	}
+	wl_list_remove(&ivisurf->surface_rotation.link);
+	wl_list_remove(&ivisurf->layer_rotation.link);
+	wl_list_remove(&ivisurf->surface_pos.link);
+	wl_list_remove(&ivisurf->layer_pos.link);
+	wl_list_remove(&ivisurf->scaling.link);
+
+	wl_list_remove(&ivisurf->pending.link);
+	wl_list_remove(&ivisurf->order.link);
+	wl_list_remove(&ivisurf->link);
 	remove_ordersurface_from_layer(ivisurf);
 
 	wl_signal_emit(&layout->surface_notification.removed, ivisurf);
@@ -350,28 +349,9 @@ ivi_layout_surface_remove(struct ivi_layout_surface *ivisurf)
 
 	ivi_layout_surface_remove_notification(ivisurf);
 
-	free(ivisurf);
-}
-
-/**
- * Called at destruction of ivi_surface
- */
-static void
-westonsurface_destroy_from_ivisurface(struct wl_listener *listener, void *data)
-{
-	struct ivi_layout_surface *ivisurf = NULL;
-
-	ivisurf = container_of(listener, struct ivi_layout_surface,
-			       surface_destroy_listener);
-
-	wl_list_remove(&ivisurf->surface_rotation.link);
-	wl_list_remove(&ivisurf->layer_rotation.link);
-	wl_list_remove(&ivisurf->surface_pos.link);
-	wl_list_remove(&ivisurf->layer_pos.link);
-	wl_list_remove(&ivisurf->scaling.link);
-
 	ivisurf->surface = NULL;
-	ivi_layout_surface_remove(ivisurf);
+
+	free(ivisurf);
 }
 
 /**
@@ -2812,10 +2792,6 @@ ivi_layout_surface_create(struct weston_surface *wl_surface,
 	ivisurf->layout = layout;
 
 	ivisurf->surface = wl_surface;
-	ivisurf->surface_destroy_listener.notify =
-		westonsurface_destroy_from_ivisurface;
-	wl_resource_add_destroy_listener(wl_surface->resource,
-					 &ivisurf->surface_destroy_listener);
 
 	tmpview = weston_view_create(wl_surface);
 	if (tmpview == NULL) {
diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index f9c2583..a147353 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -130,6 +130,22 @@ ivi_shell_surface_configure(struct weston_surface *surface,
 	}
 }
 
+static void
+layout_surface_cleanup(struct ivi_shell_surface *ivisurf)
+{
+	assert(ivisurf->layout_surface != NULL);
+
+	ivi_layout_surface_destroy(ivisurf->layout_surface);
+	ivisurf->layout_surface = NULL;
+
+	ivisurf->surface->configure = NULL;
+	ivisurf->surface->configure_private = NULL;
+	ivisurf->surface = NULL;
+
+	// destroy weston_surface destroy signal.
+	wl_list_remove(&ivisurf->surface_destroy_listener.link);
+}
+
 /*
  * The ivi_surface wl_resource destructor.
  *
@@ -154,14 +170,8 @@ shell_handle_surface_destroy(struct wl_listener *listener, void *data)
 
 	assert(ivisurf != NULL);
 
-	if (ivisurf->surface!=NULL) {
-		ivisurf->surface->configure = NULL;
-		ivisurf->surface->configure_private = NULL;
-		ivisurf->surface = NULL;
-	}
-
-	wl_list_remove(&ivisurf->surface_destroy_listener.link);
-	wl_list_remove(&ivisurf->link);
+	if (ivisurf->layout_surface != NULL)
+		layout_surface_cleanup(ivisurf);
 
 	if (ivisurf->resource != NULL) {
 		wl_resource_set_user_data(ivisurf->resource, NULL);
-- 
1.8.3.1



More information about the wayland-devel mailing list