From c3e626405f9bf0d0a005a4eb2274215ec3713c1b Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Sun, 12 May 2024 20:02:50 +0200 Subject: [PATCH] wayland/pointer-constraints: Disconnect focus surface handler early When meta_wayland_pointer_constraint_remove() is called, it can trigger a meta_wayland_event_handler_invalidate_focus() via: meta_wayland_pointer_constraint_destroy() meta_wayland_pointer_constraint_disable() meta_wayland_input_detach_event_handler() meta_wayland_input_invalidate_all_focus() meta_wayland_event_handler_invalidate_focus() Which then would result in a "focus-surface-changed" signal which would call meta_wayland_pointer_constraint_remove() a second time. This happens after surface_remove_pointer_constraints() has already been called in the first meta_wayland_pointer_constraint_remove() call, leading to "data" being NULL. To prevent this issue disconnect the signal handler before calling meta_wayland_pointer_constraint_disable() when destroying a constraint. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3476 Part-of: --- .../meta-wayland-pointer-constraints.c | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c index 4f8cc3196..069ee29ba 100644 --- a/src/wayland/meta-wayland-pointer-constraints.c +++ b/src/wayland/meta-wayland-pointer-constraints.c @@ -433,6 +433,9 @@ meta_wayland_pointer_constraint_disable (MetaWaylandPointerConstraint *constrain void meta_wayland_pointer_constraint_destroy (MetaWaylandPointerConstraint *constraint) { + g_clear_signal_handler (&constraint->pointer_focus_surface_handler_id, + constraint->seat->pointer); + if (meta_wayland_pointer_constraint_is_enabled (constraint)) meta_wayland_pointer_constraint_disable (constraint); @@ -1133,18 +1136,6 @@ bind_pointer_constraints (struct wl_client *client, NULL); } -static void -meta_wayland_pointer_constraint_finalize (GObject *object) -{ - MetaWaylandPointerConstraint *constraint = - META_WAYLAND_POINTER_CONSTRAINT (object); - - g_clear_signal_handler (&constraint->pointer_focus_surface_handler_id, - constraint->seat->pointer); - - G_OBJECT_CLASS (meta_wayland_pointer_constraint_parent_class)->finalize (object); -} - void meta_wayland_pointer_constraints_init (MetaWaylandCompositor *compositor) { @@ -1162,11 +1153,6 @@ meta_wayland_pointer_constraint_init (MetaWaylandPointerConstraint *constraint) static void meta_wayland_pointer_constraint_class_init (MetaWaylandPointerConstraintClass *klass) { - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = meta_wayland_pointer_constraint_finalize; - quark_pending_constraint_state = g_quark_from_static_string ("-meta-wayland-pointer-constraint-pending_state"); quark_surface_pointer_constraints_data =