clients: Fix crash when removing and reinserting outputs

If we don't receive a surface_leave before an output_destroy, the window
output lists can hold a stale reference to the destroyed output.

Call surface_leave for the output on all windows to make sure it's not on
any lists.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
Derek Foreman 2026-04-01 20:04:31 -05:00 committed by Pekka Paalanen
parent a879fff2ec
commit be1e58beec

View file

@ -5946,6 +5946,19 @@ display_destroy_output(struct display *d, uint32_t id)
wl_list_for_each(output, &d->output_list, link) {
if (output->server_output_id == id) {
struct window *window;
/* If a window was on a destroyed output, we need to
* make sure the output doesn't linger on the window's
* output list.
* surface_leave does nothing if the output isn't on
* the list, so we can call it for all windows to remove
* this output.
*/
wl_list_for_each(window, &d->window_list, link) {
surface_leave(window, NULL, output->output);
}
output_destroy(output);
break;
}