diff --git a/clutter/clutter/clutter-seat-private.h b/clutter/clutter/clutter-seat-private.h new file mode 100644 index 000000000..2adb7bcd6 --- /dev/null +++ b/clutter/clutter/clutter-seat-private.h @@ -0,0 +1,31 @@ +/* + * Clutter. + * + * An OpenGL based 'interactive canvas' library. + * + * Copyright (C) 2021 Red Hat Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + */ + +#ifndef CLUTTER_SEAT_PRIVATE_H +#define CLUTTER_SEAT_PRIVATE_H + +#include "clutter/clutter-types.h" + +CLUTTER_EXPORT +void clutter_seat_destroy (ClutterSeat *seat); + +#endif /* CLUTTER_SEAT_PRIVATE_H */ diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c index 8236f2609..4aa8e7abb 100644 --- a/clutter/clutter/clutter-seat.c +++ b/clutter/clutter/clutter-seat.c @@ -30,6 +30,7 @@ #include "clutter-mutter.h" #include "clutter-private.h" #include "clutter-seat.h" +#include "clutter-seat-private.h" #include "clutter-virtual-input-device.h" enum @@ -708,3 +709,10 @@ clutter_seat_query_state (ClutterSeat *seat, coords, modifiers); } + +void +clutter_seat_destroy (ClutterSeat *seat) +{ + g_object_run_dispose (G_OBJECT (seat)); + g_object_unref (seat); +} diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c index 609f690ac..f2b7bd89a 100644 --- a/src/backends/meta-backend.c +++ b/src/backends/meta-backend.c @@ -64,6 +64,7 @@ #include "backends/meta-stage-private.h" #include "backends/x11/meta-backend-x11.h" #include "clutter/clutter-mutter.h" +#include "clutter/clutter-seat-private.h" #include "meta/main.h" #include "meta/meta-backend.h" #include "meta/util.h" @@ -245,7 +246,7 @@ meta_backend_dispose (GObject *object) g_clear_object (&priv->profiler); #endif - g_clear_object (&priv->default_seat); + g_clear_pointer (&priv->default_seat, clutter_seat_destroy); g_clear_object (&priv->clutter_backend); G_OBJECT_CLASS (meta_backend_parent_class)->dispose (object); diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c index 133bf58fe..6dcc284ef 100644 --- a/src/backends/native/meta-seat-native.c +++ b/src/backends/native/meta-seat-native.c @@ -224,33 +224,22 @@ meta_seat_native_get_property (GObject *object, } static void -meta_seat_native_finalize (GObject *object) +meta_seat_native_dispose (GObject *object) { MetaSeatNative *seat = META_SEAT_NATIVE (object); - GList *iter; - if (seat->xkb_keymap) - xkb_keymap_unref (seat->xkb_keymap); + g_clear_pointer (&seat->xkb_keymap, xkb_keymap_unref); g_clear_object (&seat->core_pointer); g_clear_object (&seat->core_keyboard); g_clear_pointer (&seat->impl, meta_seat_impl_destroy); - - for (iter = seat->devices; iter; iter = g_list_next (iter)) - { - ClutterInputDevice *device = iter->data; - - g_object_unref (device); - } - g_list_free (seat->devices); - - g_hash_table_destroy (seat->reserved_virtual_slots); - + g_list_free_full (g_steal_pointer (&seat->devices), g_object_unref); + g_clear_pointer (&seat->reserved_virtual_slots, g_hash_table_destroy); g_clear_pointer (&seat->tablet_cursors, g_hash_table_unref); - g_object_unref (seat->cursor_renderer); + g_clear_object (&seat->cursor_renderer); - g_free (seat->seat_id); + g_clear_pointer (&seat->seat_id, g_free); - G_OBJECT_CLASS (meta_seat_native_parent_class)->finalize (object); + G_OBJECT_CLASS (meta_seat_native_parent_class)->dispose (object); } static ClutterInputDevice * @@ -381,7 +370,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass) object_class->constructed = meta_seat_native_constructed; object_class->set_property = meta_seat_native_set_property; object_class->get_property = meta_seat_native_get_property; - object_class->finalize = meta_seat_native_finalize; + object_class->dispose = meta_seat_native_dispose; seat_class->get_pointer = meta_seat_native_get_pointer; seat_class->get_keyboard = meta_seat_native_get_keyboard;