[06/13] ivi-shell: fix ivi_shell_surface lifetime

Submitted by Nobuhiko Tanibata on June 22, 2015, 6:31 a.m.

Details

Message ID 1434954668-26766-1-git-send-email-nobuhiko_tanibata@xddp.denso.co.jp
State Accepted
Commit 680984234a4462a3b1949559d406eefb06e2bd3b
Headers show

Not browsing as part of any series.

Commit Message

Nobuhiko Tanibata June 22, 2015, 6:31 a.m.
From: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>

ivi_shell_surface lifetime shall follow the ivi_surface protocol object
lifetime, and frees the ivi-id by destroying the ivi_layout_surface
from both wl_surface and ivi_surface destruction as the protocol specifies.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
---
 ivi-shell/ivi-shell.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index a147353..896ba1b 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -155,9 +155,18 @@  static void
 shell_destroy_shell_surface(struct wl_resource *resource)
 {
 	struct ivi_shell_surface *ivisurf = wl_resource_get_user_data(resource);
-	if (ivisurf != NULL) {
-		ivisurf->resource = NULL;
-	}
+
+	if (ivisurf == NULL)
+		return;
+
+	assert(ivisurf->resource == resource);
+
+	if (ivisurf->layout_surface != NULL)
+		layout_surface_cleanup(ivisurf);
+
+	wl_list_remove(&ivisurf->link);
+
+	free(ivisurf);
 }
 
 /* Gets called through the weston_surface destroy signal. */
@@ -172,13 +181,6 @@  shell_handle_surface_destroy(struct wl_listener *listener, void *data)
 
 	if (ivisurf->layout_surface != NULL)
 		layout_surface_cleanup(ivisurf);
-
-	if (ivisurf->resource != NULL) {
-		wl_resource_set_user_data(ivisurf->resource, NULL);
-		ivisurf->resource = NULL;
-	}
-	free(ivisurf);
-
 }
 
 /* Gets called, when a client sends ivi_surface.destroy request. */