From 0ca9d889260bf8d2bb29bcfe5809a199e9372095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 25 Jun 2019 20:22:23 +0200 Subject: [PATCH] screen: Destroy window actors after windows while unmanaging compositor After commit 2e64457f4 we destroy window actors as part of compositor destruction, however this might emit 'actor-removed' signals on window groups that the shell could use to access to resources that are already free'd at this point (like the destroyed screen, in gnome-shell's Panel._updateSolidStyle()). So, move the actor destructions under in a new function and destroy the window actors as part of compositor unmanage step, just after that all the windows are unmanaged (as they need to have an actor around). Fixes https://gitlab.gnome.org/GNOME/mutter/issues/652 --- src/compositor/compositor-private.h | 2 ++ src/compositor/compositor.c | 30 ++++++++++++++++------------- src/core/screen.c | 3 +++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h index 4669bc5cb..4582792d4 100644 --- a/src/compositor/compositor-private.h +++ b/src/compositor/compositor-private.h @@ -73,4 +73,6 @@ MetaCloseDialog * meta_compositor_create_close_dialog (MetaCompositor *composito MetaInhibitShortcutsDialog * meta_compositor_create_inhibit_shortcuts_dialog (MetaCompositor *compositor, MetaWindow *window); +void meta_compositor_unmanage_window_actors (MetaCompositor *compositor); + #endif /* META_COMPOSITOR_PRIVATE_H */ diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c index 2545d2c0e..6d045339c 100644 --- a/src/compositor/compositor.c +++ b/src/compositor/compositor.c @@ -145,19 +145,6 @@ meta_compositor_destroy (MetaCompositor *compositor) clutter_threads_remove_repaint_func (compositor->pre_paint_func_id); clutter_threads_remove_repaint_func (compositor->post_paint_func_id); - if (compositor->top_window_actor) - { - g_signal_handlers_disconnect_by_func (compositor->top_window_actor, - on_top_window_actor_destroyed, - compositor); - compositor->top_window_actor = NULL; - } - - g_clear_pointer (&compositor->window_group, clutter_actor_destroy); - g_clear_pointer (&compositor->top_window_group, clutter_actor_destroy); - g_clear_pointer (&compositor->feedback_group, clutter_actor_destroy); - g_clear_pointer (&compositor->windows, g_list_free); - if (compositor->have_x11_sync_object) meta_sync_ring_destroy (); } @@ -610,6 +597,23 @@ meta_compositor_unmanage (MetaCompositor *compositor) } } +void +meta_compositor_unmanage_window_actors (MetaCompositor *compositor) +{ + if (compositor->top_window_actor) + { + g_signal_handlers_disconnect_by_func (compositor->top_window_actor, + on_top_window_actor_destroyed, + compositor); + compositor->top_window_actor = NULL; + } + + g_clear_pointer (&compositor->window_group, clutter_actor_destroy); + g_clear_pointer (&compositor->top_window_group, clutter_actor_destroy); + g_clear_pointer (&compositor->feedback_group, clutter_actor_destroy); + g_clear_pointer (&compositor->windows, g_list_free); +} + /** * meta_shape_cow_for_window: * @compositor: A #MetaCompositor diff --git a/src/core/screen.c b/src/core/screen.c index d7623f3fb..2e59754d1 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -41,6 +41,7 @@ #include "stack.h" #include #include +#include "compositor-private.h" #include "core.h" #include "meta-cursor-tracker-private.h" #include "boxes-private.h" @@ -844,6 +845,8 @@ meta_screen_free (MetaScreen *screen, meta_display_unmanage_windows_for_screen (display, screen, timestamp); + meta_compositor_unmanage_window_actors (display->compositor); + meta_prefs_remove_listener (prefs_changed_callback, screen); meta_screen_ungrab_keys (screen);