aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShootingStarDragons <ShootingStarDragons@protonmail.com>2024-10-07 18:49:44 +0900
committerSimon Ser <contact@emersion.fr>2024-10-13 13:54:25 +0200
commit91be6e8a09fd8d4b556ff81efc1846943f5c44ea (patch)
tree49dc224836b926b8a7a167f17b2ec17e4b33b355
parent63005491cfa374c1eb56f5ca6981a8f39961f67e (diff)
fix: sway crashes if switch to another workspace with surface when IME popup is shown
in pr https://github.com/swaywm/sway/pull/8196, when im_popup_surface is unmapped, author set the popup->relative to NULL, butt popup is still in popup groups, where assert the relative is not NULL, this cause the panic Take the suggestion of Nefsen402, remove the line where set relative to NULL, and add NULL check in scene_descriptor_destory (cherry picked from commit f855b0898bf00285d5a7b840963b327230486632)
-rw-r--r--sway/input/text_input.c1
-rw-r--r--sway/scene_descriptor.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/sway/input/text_input.c b/sway/input/text_input.c
index 6bcd0234..e1672467 100644
--- a/sway/input/text_input.c
+++ b/sway/input/text_input.c
@@ -454,6 +454,7 @@ static void handle_im_popup_surface_unmap(struct wl_listener *listener, void *da
struct sway_input_popup *popup =
wl_container_of(listener, popup, popup_surface_unmap);
+ scene_descriptor_destroy(&popup->scene_tree->node, SWAY_SCENE_DESC_POPUP);
// relative should already be freed as it should be a child of the just unmapped scene
popup->desc.relative = NULL;
diff --git a/sway/scene_descriptor.c b/sway/scene_descriptor.c
index a30d4664..92bdda00 100644
--- a/sway/scene_descriptor.c
+++ b/sway/scene_descriptor.c
@@ -39,6 +39,9 @@ void *scene_descriptor_try_get(struct wlr_scene_node *node,
void scene_descriptor_destroy(struct wlr_scene_node *node,
enum sway_scene_descriptor_type type) {
struct scene_descriptor *desc = scene_node_get_descriptor(node, type);
+ if (!desc) {
+ return;
+ }
descriptor_destroy(desc);
}