From c0dfeaf15665c45122039864074f7d45f6692fa0 Mon Sep 17 00:00:00 2001 From: Pablo Saavedra Date: Mon, 9 Jun 2025 12:40:18 +0200 Subject: [PATCH] frontend: Assign output before registry shared output init Set the shared output's Weston output reference before obtaining the registry from the parent display. Ensures proper access to output context during registry event handling. Also prevent weston_seat_init when shared output lacks a compositor, avoiding crashes on invalid initialization. Signed-off-by: Pablo Saavedra --- frontend/screen-share.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/screen-share.c b/frontend/screen-share.c index 305bab186..7f46864b8 100644 --- a/frontend/screen-share.c +++ b/frontend/screen-share.c @@ -371,7 +371,13 @@ ss_seat_create(struct shared_output *so, uint32_t id) if (seat == NULL) return NULL; - weston_seat_init(&seat->base, so->output->compositor, "screen-share"); + if (so->output) { + weston_seat_init(&seat->base, so->output->compositor, "screen-share"); + } else { + weston_log("Skip seat creation the screen share output has not an output compositor\n"); + return NULL; + } + seat->output = so; seat->id = id; seat->parent.seat = wl_registry_bind(so->parent.registry, id, @@ -970,6 +976,8 @@ shared_output_create(struct weston_output *output, struct screen_share *ss, int if (!so->parent.display) goto err_alloc; + /* Set Weston output reference in the shared output before registry */ + so->output = output; so->parent.registry = wl_display_get_registry(so->parent.display); if (!so->parent.registry) goto err_display; @@ -1033,7 +1041,6 @@ shared_output_create(struct weston_output *output, struct screen_share *ss, int wl_list_init(&so->shm.buffers); wl_list_init(&so->shm.free_buffers); - so->output = output; so->output_destroyed.notify = output_destroyed; wl_signal_add(&so->output->destroy_signal, &so->output_destroyed);