diff --git a/src/xdg.c b/src/xdg.c index 9be6338b..5cddf44a 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -439,7 +439,19 @@ position_xdg_toplevel_view(struct view *view) static const char * xdg_toplevel_view_get_string_prop(struct view *view, const char *prop) { - struct wlr_xdg_toplevel *xdg_toplevel = xdg_toplevel_from_view(view); + struct xdg_toplevel_view *xdg_view = xdg_toplevel_view_from_view(view); + struct wlr_xdg_toplevel *xdg_toplevel = xdg_view->xdg_surface + ? xdg_view->xdg_surface->toplevel + : NULL; + if (!xdg_toplevel) { + /* + * This may happen due to a matchOnce rule when + * a view is destroyed while A-Tab is open. See + * https://github.com/labwc/labwc/issues/1082#issuecomment-1716137180 + */ + return ""; + } + if (!strcmp(prop, "title")) { return xdg_toplevel->title; } diff --git a/src/xwayland.c b/src/xwayland.c index b00119c6..ae405311 100644 --- a/src/xwayland.c +++ b/src/xwayland.c @@ -355,8 +355,17 @@ xwayland_view_close(struct view *view) static const char * xwayland_view_get_string_prop(struct view *view, const char *prop) { - struct wlr_xwayland_surface *xwayland_surface = - xwayland_surface_from_view(view); + struct xwayland_view *xwayland_view = xwayland_view_from_view(view); + struct wlr_xwayland_surface *xwayland_surface = xwayland_view->xwayland_surface; + if (!xwayland_surface) { + /* + * This may happen due to a matchOnce rule when + * a view is destroyed while A-Tab is open. See + * https://github.com/labwc/labwc/issues/1082#issuecomment-1716137180 + */ + return ""; + } + if (!strcmp(prop, "title")) { return xwayland_surface->title; }