1
0
Fork 0

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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3749>
This commit is contained in:
Sebastian Keller 2024-05-12 20:02:50 +02:00 committed by Marge Bot
parent d4907a960c
commit c3e626405f

View file

@ -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 =