[mutter/gnome-3-36] window-actor/wayland: Remove subsurface actors on dispose



commit 59deaeea2758397b8f261b880aad247b285c8028
Author: Robert Mader <robert mader posteo de>
Date:   Fri Aug 6 13:09:04 2021 +0200

    window-actor/wayland: Remove subsurface actors on dispose
    
    Destroying the window actor also destroys all its children. Subsurfaces
    however may get reused. If the client did not unparent them before
    the window actor got destroyed, they will be left without actor
    which results in a crash.
    
    Unparent all actors of subsurfaces on dispose to avoid that.
    
    Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1892
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>

 src/compositor/meta-window-actor-wayland.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/src/compositor/meta-window-actor-wayland.c b/src/compositor/meta-window-actor-wayland.c
index cbb995b85b..51e24214b9 100644
--- a/src/compositor/meta-window-actor-wayland.c
+++ b/src/compositor/meta-window-actor-wayland.c
@@ -141,10 +141,33 @@ meta_window_actor_wayland_update_regions (MetaWindowActor *actor)
 {
 }
 
+static void
+meta_window_actor_wayland_dispose (GObject *object)
+{
+  MetaWindowActor *window_actor = META_WINDOW_ACTOR (object);
+  MetaSurfaceActor *surface_actor =
+    meta_window_actor_get_surface (window_actor);
+  GList *children;
+  GList *l;
+
+  children = clutter_actor_get_children (CLUTTER_ACTOR (window_actor));
+  for (l = children; l; l = l->next)
+    {
+      ClutterActor *child_actor = l->data;
+
+      if (META_IS_SURFACE_ACTOR_WAYLAND (child_actor) &&
+          child_actor != CLUTTER_ACTOR (surface_actor))
+        clutter_actor_remove_child (CLUTTER_ACTOR (window_actor), child_actor);
+    }
+
+  G_OBJECT_CLASS (meta_window_actor_wayland_parent_class)->dispose (object);
+}
+
 static void
 meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
 {
   MetaWindowActorClass *window_actor_class = META_WINDOW_ACTOR_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   window_actor_class->assign_surface_actor = meta_window_actor_wayland_assign_surface_actor;
   window_actor_class->frame_complete = meta_window_actor_wayland_frame_complete;
@@ -154,6 +177,8 @@ meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
   window_actor_class->queue_destroy = meta_window_actor_wayland_queue_destroy;
   window_actor_class->set_frozen = meta_window_actor_wayland_set_frozen;
   window_actor_class->update_regions = meta_window_actor_wayland_update_regions;
+
+  object_class->dispose = meta_window_actor_wayland_dispose;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]