backend: Destroy seat explicitly

Don't let any dangling pointer keeping it alive.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
This commit is contained in:
Jonas Ådahl 2021-03-12 08:34:30 +01:00 committed by Marge Bot
parent 6ecd911dd0
commit ab600cafd2
4 changed files with 49 additions and 20 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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 */

View File

@ -30,6 +30,7 @@
#include "clutter-mutter.h" #include "clutter-mutter.h"
#include "clutter-private.h" #include "clutter-private.h"
#include "clutter-seat.h" #include "clutter-seat.h"
#include "clutter-seat-private.h"
#include "clutter-virtual-input-device.h" #include "clutter-virtual-input-device.h"
enum enum
@ -708,3 +709,10 @@ clutter_seat_query_state (ClutterSeat *seat,
coords, coords,
modifiers); modifiers);
} }
void
clutter_seat_destroy (ClutterSeat *seat)
{
g_object_run_dispose (G_OBJECT (seat));
g_object_unref (seat);
}

View File

@ -64,6 +64,7 @@
#include "backends/meta-stage-private.h" #include "backends/meta-stage-private.h"
#include "backends/x11/meta-backend-x11.h" #include "backends/x11/meta-backend-x11.h"
#include "clutter/clutter-mutter.h" #include "clutter/clutter-mutter.h"
#include "clutter/clutter-seat-private.h"
#include "meta/main.h" #include "meta/main.h"
#include "meta/meta-backend.h" #include "meta/meta-backend.h"
#include "meta/util.h" #include "meta/util.h"
@ -245,7 +246,7 @@ meta_backend_dispose (GObject *object)
g_clear_object (&priv->profiler); g_clear_object (&priv->profiler);
#endif #endif
g_clear_object (&priv->default_seat); g_clear_pointer (&priv->default_seat, clutter_seat_destroy);
g_clear_object (&priv->clutter_backend); g_clear_object (&priv->clutter_backend);
G_OBJECT_CLASS (meta_backend_parent_class)->dispose (object); G_OBJECT_CLASS (meta_backend_parent_class)->dispose (object);

View File

@ -224,33 +224,22 @@ meta_seat_native_get_property (GObject *object,
} }
static void static void
meta_seat_native_finalize (GObject *object) meta_seat_native_dispose (GObject *object)
{ {
MetaSeatNative *seat = META_SEAT_NATIVE (object); MetaSeatNative *seat = META_SEAT_NATIVE (object);
GList *iter;
if (seat->xkb_keymap) g_clear_pointer (&seat->xkb_keymap, xkb_keymap_unref);
xkb_keymap_unref (seat->xkb_keymap);
g_clear_object (&seat->core_pointer); g_clear_object (&seat->core_pointer);
g_clear_object (&seat->core_keyboard); g_clear_object (&seat->core_keyboard);
g_clear_pointer (&seat->impl, meta_seat_impl_destroy); g_clear_pointer (&seat->impl, meta_seat_impl_destroy);
g_list_free_full (g_steal_pointer (&seat->devices), g_object_unref);
for (iter = seat->devices; iter; iter = g_list_next (iter)) g_clear_pointer (&seat->reserved_virtual_slots, g_hash_table_destroy);
{
ClutterInputDevice *device = iter->data;
g_object_unref (device);
}
g_list_free (seat->devices);
g_hash_table_destroy (seat->reserved_virtual_slots);
g_clear_pointer (&seat->tablet_cursors, g_hash_table_unref); 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 * static ClutterInputDevice *
@ -381,7 +370,7 @@ meta_seat_native_class_init (MetaSeatNativeClass *klass)
object_class->constructed = meta_seat_native_constructed; object_class->constructed = meta_seat_native_constructed;
object_class->set_property = meta_seat_native_set_property; object_class->set_property = meta_seat_native_set_property;
object_class->get_property = meta_seat_native_get_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_pointer = meta_seat_native_get_pointer;
seat_class->get_keyboard = meta_seat_native_get_keyboard; seat_class->get_keyboard = meta_seat_native_get_keyboard;