From b41094ef5f70fe4511dd73b28d4075401d32a3d0 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Thu, 30 Jan 2020 09:19:39 +0100 Subject: [PATCH] x11-selection: Unref owners and cancellables on shutdown Selection owners are set using g_set_object in source_new_cb, but that reference is never removed on shutdown. Similarly the cancellables created in handle_xfixes_selection_notify are never freed on shutdown. Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006 https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001 --- src/x11/meta-x11-selection.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/x11/meta-x11-selection.c b/src/x11/meta-x11-selection.c index fbb46d680..a93fa1585 100644 --- a/src/x11/meta-x11-selection.c +++ b/src/x11/meta-x11-selection.c @@ -442,10 +442,22 @@ void meta_x11_selection_shutdown (MetaX11Display *x11_display) { MetaDisplay *display = meta_get_display (); + guint i; g_signal_handlers_disconnect_by_func (meta_display_get_selection (display), owner_changed_cb, x11_display); + + for (i = 0; i < META_N_SELECTION_TYPES; i++) + { + g_clear_object (&x11_display->selection.owners[i]); + if (x11_display->selection.cancellables[i]) + { + g_cancellable_cancel (x11_display->selection.cancellables[i]); + g_clear_object (&x11_display->selection.cancellables[i]); + } + } + if (x11_display->selection.xwindow != None) { XDestroyWindow (x11_display->xdisplay, x11_display->selection.xwindow);