headless-server::shell : Fix crash 75/207175/1
authorlsj119 <lsj119@samsung.com>
Tue, 30 Apr 2019 02:28:40 +0000 (11:28 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 30 May 2019 08:33:56 +0000 (17:33 +0900)
Change-Id: I5749f41627be27e6b449e60d78d177b27dcaabbc

src/bin/headless/shell/shell.c
src/samples/headless_client.c

index 5c28b0e8a0f9570ba8b2e846dc9dbfcdb2909395..b6284b68b9ba140e1a3a3af8dcd343582d13b00a 100644 (file)
@@ -465,6 +465,7 @@ zxdg_shell_cb_surface_get(struct wl_client *client, struct wl_resource *resource
        headless_shell_t *hs;
        headless_shell_surface_t *hs_surface = NULL;
        pepper_surface_t *psurface;
+       const char *role;
 
        hs = wl_resource_get_user_data(resource);
        if (!hs) {
@@ -513,11 +514,16 @@ zxdg_shell_cb_surface_get(struct wl_client *client, struct wl_resource *resource
        hs_surface->cb_commit = pepper_object_add_event_listener((pepper_object_t *)psurface,
                                                                                                                        PEPPER_EVENT_SURFACE_COMMIT, 0, headless_shell_cb_surface_commit, hs_surface);
 
-       if (!pepper_surface_set_role(psurface, "xdg_surface")) {
-               PEPPER_ERROR("fail to set role\n");
-               wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
-                               "Assign \"xdg_surface\" to wl_surface failed\n");
-               goto error;
+       role = pepper_surface_get_role(psurface);
+       if (!role) {
+               if (!pepper_surface_set_role(psurface, "xdg_surface")) {
+                       PEPPER_ERROR("fail to set role\n");
+                       wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
+                                       "Assign \"xdg_surface\" to wl_surface failed\n");
+                       goto error;
+               }
+       } else {
+               PEPPER_CHECK(!strcmp(role, "xdg_surface"), goto error, "surface has alweady role %s\n", role);
        }
 
        PEPPER_TRACE("[SHELL] create zxdg_surface:%p, pview:%p, psurface:%p\n",
@@ -528,11 +534,15 @@ zxdg_shell_cb_surface_get(struct wl_client *client, struct wl_resource *resource
        return;
 error:
        if (hs_surface) {
-               if (hs_surface->view)
+               if (hs_surface->view) {
                        pepper_view_destroy(hs_surface->view);
+                       hs_surface->view = NULL;
+               }
 
-               if (hs_surface->zxdg_shell_surface)
+               if (hs_surface->zxdg_shell_surface) {
                        wl_resource_destroy(hs_surface->zxdg_shell_surface);
+                       hs_surface->zxdg_shell_surface = NULL;
+               }
        }
 }
 
index a6fb818e9b7bb0f3c2c16da15a1549d9638c2ed4..dae0286391160a14f8924dacf29c313e2a829de7 100644 (file)
@@ -442,6 +442,7 @@ _stdin_cb(void *data, Ecore_Fd_Handler *handler EINA_UNUSED)
        }
        else if (!strncmp(tmp, "hide", sizeof("hide"))) {
                ecore_wl2_window_hide(client->win);
+               ecore_wl2_window_commit(client->win, EINA_TRUE);
                printf("hide window\n");
        }
        else if (!strncmp(tmp, "show", sizeof("show"))) {