This should fix some (fairly rare) crashes where the client goes away at exactly
the wrong moment, e.g.:
- Weston sends a message to the client
- Message causes the client to crash for whatever reason
- Weston keeps processing the remaining requests from the now dead client
(I've only seen it happen once, while stepping through Weston's code in gdb, but
seems like the right thing to fix.)
Signed-off-by: Dima Ryazanov
---
libweston-desktop/xdg-shell-v6.c | 141 ---
1 file changed, 101 insertions(+), 40 deletions(-)
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index 7d0bd8e..30f6d82 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -302,10 +302,14 @@ weston_desktop_xdg_toplevel_protocol_set_parent(struct
wl_client *wl_client,
{
struct weston_desktop_surface *dsurface =
wl_resource_get_user_data(resource);
- struct weston_desktop_xdg_toplevel *toplevel =
- weston_desktop_surface_get_implementation_data(dsurface);
+ struct weston_desktop_xdg_toplevel *toplevel;
struct weston_desktop_surface *parent = NULL;
+ if (!dsurface)
+ return;
+
+ toplevel = weston_desktop_surface_get_implementation_data(dsurface);
+
if (parent_resource != NULL)
parent = wl_resource_get_user_data(parent_resource);
@@ -346,8 +350,12 @@
weston_desktop_xdg_toplevel_protocol_show_window_menu(struct wl_client *wl_clien
wl_resource_get_user_data(resource);
struct weston_seat *seat =
wl_resource_get_user_data(seat_resource);
- struct weston_desktop_xdg_toplevel *toplevel =
- weston_desktop_surface_get_implementation_data(dsurface);
+ struct weston_desktop_xdg_toplevel *toplevel;
+
+ if (!dsurface)
+ return;
+
+ toplevel = weston_desktop_surface_get_implementation_data(dsurface);
if (!toplevel->base.configured) {
wl_resource_post_error(toplevel->resource,
@@ -370,8 +378,12 @@ weston_desktop_xdg_toplevel_protocol_move(struct wl_client
*wl_client,
wl_resource_get_user_data(resource);
struct weston_seat *seat =
wl_resource_get_user_data(seat_resource);
- struct weston_desktop_xdg_toplevel *toplevel =
- weston_desktop_surface_get_implementation_data(dsurface);
+ struct weston_desktop_xdg_toplevel *toplevel;
+
+ if (!dsurface)
+ return;
+
+ toplevel = weston_desktop_surface_get_implementation_data(dsurface);
if (!toplevel->base.configured) {
wl_resource_post_error(toplevel->resource,
@@ -394,11 +406,15 @@ weston_desktop_xdg_toplevel_protocol_resize(struct
wl_client *wl_client,
wl_resource_get_user_data(resource);
struct weston_seat *seat =
wl_resource_get_user_data(seat_resource);
- struct weston_desktop_xdg_toplevel *toplevel =
- weston_desktop_surface_get_implementation_data(dsurface);
+ struct weston_desktop_xdg_toplevel *toplevel;
enum weston_desktop_surface_edge surf_edges =
(enum weston_desktop_surface_edge) edges;
+ if (!dsurface)
+ return;
+
+ toplevel = weston_desktop_surface_get_implementation_data(dsurface);
+
if (!toplevel->base.configured) {
wl_resource_post_error(toplevel->resource,
ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED,
@@ -423,9 +439,12 @@ weston_desktop_xdg_toplevel_protocol_set_min_size(struct
wl_client *wl_client,
{
struct weston_desktop_surface *dsurface =
wl_resource_get_user_data(resource);
- struct weston_desktop_xdg_toplevel *toplevel =
- weston_desktop_surface_get_implementation_data(dsurface);
+ struct weston_desktop_xdg_toplevel *toplevel;
+ if (!dsurface)
+ return;
+
+ toplevel = weston_desktop_surface_get_implementation_data(dsurface);
toplevel->next_min_size.width = width;
toplevel->next_min_size.height = height;
}
@@ -437,9 +456,12 @@ weston_desktop_xdg_toplevel_protocol_set_max_size(struct
wl_client *wl_client,
{
struct weston_desktop_surface *dsurface =
wl_resource_get_user_data(resource);
- struct weston_desktop_xdg_toplevel *toplevel =
- weston_desktop_surface_get_implementation_data(dsurface);
+ struct weston_desktop_xdg_toplevel *toplevel;
+
+ if (!dsurface)
+ return;
+ toplevel = weston_desktop_surface_get_implementation_data(dsurface);
toplevel->next_max_size.width = width;
toplevel->next_max_size.height = height;
}
@@ -450,9 +472,12 @@ weston_desktop_xdg_toplevel_protocol_set_maximized(struct
wl_client *wl_client,
{
struct weston_desktop_surface *dsurface =