1From 0464abb571f35d7086222b007dd5f1a2303b2f32 Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Tue, 12 Jul 2022 12:29:57 +0800
4Subject: [PATCH 05/10] xdg-shell{,-v6}: Fix crash when unbind early
5
6Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
7---
8 src/modules/wl_desktop_shell/xdg.c  | 7 +++++--
9 src/modules/wl_desktop_shell/xdg6.c | 7 +++++--
10 2 files changed, 10 insertions(+), 4 deletions(-)
11
12diff --git a/src/modules/wl_desktop_shell/xdg.c b/src/modules/wl_desktop_shell/xdg.c
13index 4892eaa70..0f8c973ec 100644
14--- a/src/modules/wl_desktop_shell/xdg.c
15+++ b/src/modules/wl_desktop_shell/xdg.c
16@@ -1454,8 +1454,11 @@ _xdg_client_destroy(E_Client *ec, Eina_Bool do_list)
17
18         client = wl_resource_get_client(ec->comp_data->surface);
19         res = eina_hash_find(xdg_shell_resources, &client);
20-        v = wl_resource_get_user_data(res);
21-        v->surfaces = eina_list_remove(v->surfaces, shd->surface);
22+        if (res)
23+          {
24+             v = wl_resource_get_user_data(res);
25+             v->surfaces = eina_list_remove(v->surfaces, shd->surface);
26+          }
27      }
28    if (ec->comp_data->shell.surface)
29      e_shell_surface_destroy(ec->comp_data->shell.surface);
30diff --git a/src/modules/wl_desktop_shell/xdg6.c b/src/modules/wl_desktop_shell/xdg6.c
31index ce236023e..a4a85251c 100644
32--- a/src/modules/wl_desktop_shell/xdg6.c
33+++ b/src/modules/wl_desktop_shell/xdg6.c
34@@ -1429,8 +1429,11 @@ _xdg6_client_destroy(E_Client *ec, Eina_Bool do_list)
35
36         client = wl_resource_get_client(ec->comp_data->surface);
37         res = eina_hash_find(xdg_shell_resources, &client);
38-        v = wl_resource_get_user_data(res);
39-        v->surfaces = eina_list_remove(v->surfaces, shd->surface);
40+        if (res)
41+          {
42+             v = wl_resource_get_user_data(res);
43+             v->surfaces = eina_list_remove(v->surfaces, shd->surface);
44+          }
45      }
46    if (ec->comp_data->shell.surface)
47      e_shell_surface_destroy(ec->comp_data->shell.surface);
48--
492.20.1
50
51