backends/native: Protect against NULL pointer constraints

To clear a pointer constraint, the Wayland backend passes a NULL
constraint to the native input backend.

The new async API however tries to reference/un-reference the given
object to use it while running in a separate task, which leads to a
warning from GLib trying to g_object_ref()/g_object_unref() a non
GObject pointer.

To avoid that issue, simply set the data only if the given constraints
pointer is not NULL.

Suggested-by: Carlos Garnacho <carlosg@gnome.org>
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1587
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1652>
This commit is contained in:
Olivier Fourdan 2020-12-21 13:25:28 +01:00
parent 888e09a646
commit 904d7fa798

View File

@ -3333,7 +3333,8 @@ meta_seat_impl_set_pointer_constraint (MetaSeatImpl *seat,
g_return_if_fail (META_IS_SEAT_IMPL (seat)); g_return_if_fail (META_IS_SEAT_IMPL (seat));
task = g_task_new (seat, NULL, NULL, NULL); task = g_task_new (seat, NULL, NULL, NULL);
g_task_set_task_data (task, g_object_ref (constraint_impl), g_object_unref); if (constraint_impl)
g_task_set_task_data (task, g_object_ref (constraint_impl), g_object_unref);
meta_seat_impl_run_input_task (seat, task, meta_seat_impl_run_input_task (seat, task,
(GSourceFunc) set_pointer_constraint); (GSourceFunc) set_pointer_constraint);
g_object_unref (task); g_object_unref (task);