diff --git a/include/view.h b/include/view.h index 491a0c9c..9ad11cd9 100644 --- a/include/view.h +++ b/include/view.h @@ -163,7 +163,7 @@ struct view { struct workspace *workspace; struct wlr_surface *surface; struct wlr_scene_tree *scene_tree; - struct wlr_scene_tree *content_tree; + struct wlr_scene_tree *content_tree; /* may be NULL for unmapped view */ /* These are never NULL and an empty string is set instead. */ char *title; diff --git a/src/debug.c b/src/debug.c index 84b844d8..cd2ce3d2 100644 --- a/src/debug.c +++ b/src/debug.c @@ -77,7 +77,7 @@ get_view_part(struct view *view, struct wlr_scene_node *node) snprintf(view_name, sizeof(view_name), "view (%s)", view->app_id); return view_name; } - if (node == &view->content_tree->node) { + if (view->content_tree && node == &view->content_tree->node) { return "view->content_tree"; } if (view->resize_indicator.tree diff --git a/src/osd/osd-thumbnail.c b/src/osd/osd-thumbnail.c index cc34a3c2..68610896 100644 --- a/src/osd/osd-thumbnail.c +++ b/src/osd/osd-thumbnail.c @@ -74,6 +74,13 @@ render_node(struct server *server, struct wlr_render_pass *pass, static struct wlr_buffer * render_thumb(struct output *output, struct view *view) { + if (!view->content_tree) { + /* + * Defensive. Could possibly occur if view was unmapped + * with OSD already displayed. + */ + return NULL; + } struct server *server = output->server; struct wlr_buffer *buffer = wlr_allocator_create_buffer(server->allocator, view->current.width, view->current.height, diff --git a/src/view.c b/src/view.c index d2297147..f9dd3e0b 100644 --- a/src/view.c +++ b/src/view.c @@ -2517,7 +2517,11 @@ view_set_shade(struct view *view, bool shaded) view->shaded = shaded; ssd_enable_shade(view->ssd, view->shaded); - wlr_scene_node_set_enabled(&view->content_tree->node, !view->shaded); + /* An unmapped view may not have a content tree */ + if (view->content_tree) { + wlr_scene_node_set_enabled(&view->content_tree->node, + !view->shaded); + } } void