From fd24878305bb56a934d304d9e250a46d2546337f Mon Sep 17 00:00:00 2001 From: Emre Ucan Date: Thu, 17 Mar 2016 11:34:32 +0100 Subject: ilmControl: don't free surface context twice I moved the cleanup code from content listener to destroyed listener, so that we can avoid double free. Signed-off-by: Emre Ucan --- .../ilmControl/src/ilm_control_wayland_platform.c | 34 ++++++---------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c index 92278ac..21708ab 100644 --- a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c +++ b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c @@ -637,6 +637,14 @@ controller_surface_listener_destroyed(void *data, ILM_NOTIFICATION_CONTENT_REMOVED); } + if (ctx_surf->ctx->notification != NULL) { + ilmObjectType surface = ILM_SURFACE; + ctx_surf->ctx->notification(surface, ctx_surf->id_surface, ILM_FALSE, + ctx_surf->ctx->notification_user_data); + } + + ivi_controller_surface_destroy(controller, 1); + wl_list_remove(&ctx_surf->order.link); wl_list_remove(&ctx_surf->link); free(ctx_surf); @@ -649,31 +657,7 @@ controller_surface_listener_content(void *data, { struct surface_context *ctx_surf = data; - // if client surface (=content) was removed with ilm_surfaceDestroy() - // the expected behavior within ILM API mandates a full removal - // of the surface from the scene. We must remove the controller - // from scene, too. - if (IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED == content_state) - { - if (ctx_surf->notification != NULL) { - ctx_surf->notification(ctx_surf->id_surface, - &ctx_surf->prop, - ILM_NOTIFICATION_CONTENT_REMOVED); - } - - if (ctx_surf->ctx->notification != NULL) { - ilmObjectType surface = ILM_SURFACE; - ctx_surf->ctx->notification(surface, ctx_surf->id_surface, ILM_FALSE, - ctx_surf->ctx->notification_user_data); - } - - ivi_controller_surface_destroy(controller, 1); - - wl_list_remove(&ctx_surf->order.link); - wl_list_remove(&ctx_surf->link); - free(ctx_surf); - } - else if (IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_AVAILABLE == content_state) + if (IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_AVAILABLE == content_state) { if (ctx_surf->notification != NULL) { ctx_surf->notification(ctx_surf->id_surface, -- cgit v1.2.1