backend: Cleanup cursor tracker on shutdown

It keeps references to cursors, and cursors keep references to DRM
buffers. In order to be able to clean up on exit, explicitly destroy the
cursor tracker on shutdown.

We can't rely on GObject reference counting, as gjs might hold onto a
reference until it's garbage collected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
This commit is contained in:
Jonas Ådahl 2021-04-10 00:44:45 +02:00 committed by Marge Bot
parent f1a120ca36
commit 558cb4fac3
3 changed files with 13 additions and 3 deletions

View File

@ -199,6 +199,7 @@ meta_backend_dispose (GObject *object)
MetaBackend *backend = META_BACKEND (object); MetaBackend *backend = META_BACKEND (object);
MetaBackendPrivate *priv = meta_backend_get_instance_private (backend); MetaBackendPrivate *priv = meta_backend_get_instance_private (backend);
g_clear_pointer (&priv->cursor_tracker, meta_cursor_tracker_destroy);
g_clear_object (&priv->current_device); g_clear_object (&priv->current_device);
g_clear_object (&priv->monitor_manager); g_clear_object (&priv->monitor_manager);
g_clear_object (&priv->orientation_manager); g_clear_object (&priv->orientation_manager);

View File

@ -51,4 +51,6 @@ MetaBackend * meta_cursor_tracker_get_backend (MetaCursorTracker *tracker);
void meta_cursor_tracker_notify_cursor_changed (MetaCursorTracker *tracker); void meta_cursor_tracker_notify_cursor_changed (MetaCursorTracker *tracker);
void meta_cursor_tracker_destroy (MetaCursorTracker *tracker);
#endif #endif

View File

@ -190,6 +190,13 @@ meta_cursor_tracker_real_get_sprite (MetaCursorTracker *tracker)
return priv->displayed_cursor; return priv->displayed_cursor;
} }
void
meta_cursor_tracker_destroy (MetaCursorTracker *tracker)
{
g_object_run_dispose (G_OBJECT (tracker));
g_object_unref (tracker);
}
static void static void
meta_cursor_tracker_init (MetaCursorTracker *tracker) meta_cursor_tracker_init (MetaCursorTracker *tracker)
{ {
@ -244,7 +251,7 @@ meta_cursor_tracker_set_property (GObject *object,
} }
static void static void
meta_cursor_tracker_finalize (GObject *object) meta_cursor_tracker_dispose (GObject *object)
{ {
MetaCursorTracker *tracker = META_CURSOR_TRACKER (object); MetaCursorTracker *tracker = META_CURSOR_TRACKER (object);
MetaCursorTrackerPrivate *priv = MetaCursorTrackerPrivate *priv =
@ -254,7 +261,7 @@ meta_cursor_tracker_finalize (GObject *object)
g_clear_object (&priv->displayed_cursor); g_clear_object (&priv->displayed_cursor);
g_clear_object (&priv->root_cursor); g_clear_object (&priv->root_cursor);
G_OBJECT_CLASS (meta_cursor_tracker_parent_class)->finalize (object); G_OBJECT_CLASS (meta_cursor_tracker_parent_class)->dispose (object);
} }
static void static void
@ -264,7 +271,7 @@ meta_cursor_tracker_class_init (MetaCursorTrackerClass *klass)
object_class->get_property = meta_cursor_tracker_get_property; object_class->get_property = meta_cursor_tracker_get_property;
object_class->set_property = meta_cursor_tracker_set_property; object_class->set_property = meta_cursor_tracker_set_property;
object_class->finalize = meta_cursor_tracker_finalize; object_class->dispose = meta_cursor_tracker_dispose;
klass->set_force_track_position = klass->set_force_track_position =
meta_cursor_tracker_real_set_force_track_position; meta_cursor_tracker_real_set_force_track_position;