ilmClient: free resources after use
authorMarcus Fritzsch <marcus.fritzsch@xse.de>
Tue, 12 Aug 2014 07:37:57 +0000 (09:37 +0200)
committerNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
Tue, 12 Aug 2014 13:15:15 +0000 (22:15 +0900)
Signed-off-by: Marcus Fritzsch <marcus.fritzsch@xse.de>
ivi-layermanagement-api/ilmClient/src/ilm_client_wayland_platform.c

index 71fc9f1..9f38cad 100644 (file)
@@ -253,29 +253,57 @@ static const struct wl_registry_listener registry_client_listener = {
 static struct ilm_client_context ilm_context = {0};
 
 static void
+destroy_client_resouses(void);
+
+static void
 wayland_destroy(void)
 {
     struct ilm_client_context *ctx = &ilm_context;
-    ctx->valid = 0;
+    if (ctx->valid)
+    {
+        destroy_client_resouses();
+        ctx->valid = 0;
+    }
 }
 
 static void
 destroy_client_resouses(void)
 {
     struct ilm_client_context *ctx = &ilm_context;
-    struct screen_context *ctx_scrn = NULL;
-    struct screen_context *next = NULL;
-    wl_list_for_each_safe(ctx_scrn, next, &ctx->list_screen, link) {
-        if (ctx_scrn->output != NULL) {
+
+    {
+        struct surface_context *c = NULL;
+        struct surface_context *n = NULL;
+        wl_list_for_each_safe(c, n, &ctx->list_surface, link) {
+            wl_list_remove(&c->link);
+            ivi_surface_destroy(c->surface);
+            free(c);
+        }
+    }
+
+    {
+        struct screen_context *ctx_scrn = NULL;
+        struct screen_context *next = NULL;
+        wl_list_for_each_safe(ctx_scrn, next, &ctx->list_screen, link) {
+            if (ctx_scrn->output != NULL) {
+                wl_output_destroy(ctx_scrn->output);
+            }
+
             wl_list_remove(&ctx_scrn->link);
-            wl_output_destroy(ctx_scrn->output);
             free(ctx_scrn);
         }
     }
+
     if (ctx->ivi_application != NULL) {
         ivi_application_destroy(ctx->ivi_application);
         ctx->ivi_application = NULL;
     }
+
+    if (ctx->registry)
+    {
+        wl_registry_destroy(ctx->registry);
+        ctx->registry = NULL;
+    }
 }
 
 static ilmErrorTypes