From 4c48c859eaef7799701e81deaa8c4c8e3324455e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 1 Nov 2019 13:16:25 +0100 Subject: [PATCH] plugins/default: Clean up tile preview when closing display On finalize, the preview actor will have been destroyed behind our back; avoid that by cleaning up before it's too late. https://gitlab.gnome.org/GNOME/mutter/merge_requests/912 --- src/compositor/plugins/default.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/compositor/plugins/default.c b/src/compositor/plugins/default.c index 42d28ec20..378009006 100644 --- a/src/compositor/plugins/default.c +++ b/src/compositor/plugins/default.c @@ -737,9 +737,8 @@ destroy (MetaPlugin *plugin, MetaWindowActor *window_actor) * Tile preview private data accessor */ static void -free_display_tile_preview (gpointer data) +free_display_tile_preview (DisplayTilePreview *preview) { - DisplayTilePreview *preview = data; if (G_LIKELY (preview != NULL)) { clutter_actor_destroy (preview->actor); @@ -747,6 +746,13 @@ free_display_tile_preview (gpointer data) } } +static void +on_display_closing (MetaDisplay *display, + DisplayTilePreview *preview) +{ + free_display_tile_preview (preview); +} + static DisplayTilePreview * get_display_tile_preview (MetaDisplay *display) { @@ -769,9 +775,13 @@ get_display_tile_preview (MetaDisplay *display) clutter_actor_set_opacity (preview->actor, 100); clutter_actor_add_child (meta_get_window_group_for_display (display), preview->actor); - g_object_set_qdata_full (G_OBJECT (display), - display_tile_preview_data_quark, preview, - free_display_tile_preview); + g_signal_connect (display, + "closing", + G_CALLBACK (on_display_closing), + preview); + g_object_set_qdata (G_OBJECT (display), + display_tile_preview_data_quark, + preview); } return preview;