Skip to content

Commit 830364e

Browse files
Sunderland93mtwebster
authored andcommitted
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.
1 parent ea04651 commit 830364e

3 files changed

Lines changed: 29 additions & 16 deletions

File tree

src/compositor/meta-window-actor-wayland.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,33 @@ meta_window_actor_wayland_update_regions (MetaWindowActor *actor)
144144
{
145145
}
146146

147+
static void
148+
meta_window_actor_wayland_dispose (GObject *object)
149+
{
150+
MetaWindowActor *window_actor = META_WINDOW_ACTOR (object);
151+
MetaSurfaceActor *surface_actor =
152+
meta_window_actor_get_surface (window_actor);
153+
GList *children;
154+
GList *l;
155+
156+
children = clutter_actor_get_children (CLUTTER_ACTOR (window_actor));
157+
for (l = children; l; l = l->next)
158+
{
159+
ClutterActor *child_actor = l->data;
160+
161+
if (META_IS_SURFACE_ACTOR_WAYLAND (child_actor) &&
162+
child_actor != CLUTTER_ACTOR (surface_actor))
163+
clutter_actor_remove_child (CLUTTER_ACTOR (window_actor), child_actor);
164+
}
165+
166+
G_OBJECT_CLASS (meta_window_actor_wayland_parent_class)->dispose (object);
167+
}
168+
147169
static void
148170
meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
149171
{
150172
MetaWindowActorClass *window_actor_class = META_WINDOW_ACTOR_CLASS (klass);
173+
GObjectClass *object_class = G_OBJECT_CLASS (klass);
151174

152175
window_actor_class->assign_surface_actor = meta_window_actor_wayland_assign_surface_actor;
153176
window_actor_class->frame_complete = meta_window_actor_wayland_frame_complete;
@@ -157,6 +180,8 @@ meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
157180
window_actor_class->queue_destroy = meta_window_actor_wayland_queue_destroy;
158181
window_actor_class->set_frozen = meta_window_actor_wayland_set_frozen;
159182
window_actor_class->update_regions = meta_window_actor_wayland_update_regions;
183+
184+
object_class->dispose = meta_window_actor_wayland_dispose;
160185
}
161186

162187
static void

src/wayland/meta-wayland-subsurface.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ unparent_actor (MetaWaylandSurface *surface)
292292
return;
293293

294294
parent_actor = clutter_actor_get_parent (actor);
295-
clutter_actor_remove_child (parent_actor, actor);
295+
if (parent_actor)
296+
clutter_actor_remove_child (parent_actor, actor);
296297
}
297298

298299
static void
@@ -490,6 +491,7 @@ surface_handle_parent_surface_destroyed (struct wl_listener *listener,
490491
surface,
491492
sub.parent_destroy_listener);
492493

494+
g_node_unlink (surface->subsurface_branch_node);
493495
surface->sub.parent = NULL;
494496
}
495497

src/wayland/meta-wayland-surface.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,13 +1328,6 @@ meta_wayland_surface_notify_unmapped (MetaWaylandSurface *surface)
13281328
g_signal_emit (surface, surface_signals[SURFACE_UNMAPPED], 0);
13291329
}
13301330

1331-
static void
1332-
unlink_note (GNode *node,
1333-
gpointer data)
1334-
{
1335-
g_node_unlink (node);
1336-
}
1337-
13381331
static void
13391332
wl_surface_destructor (struct wl_resource *resource)
13401333
{
@@ -1383,14 +1376,7 @@ wl_surface_destructor (struct wl_resource *resource)
13831376
if (surface->wl_subsurface)
13841377
wl_resource_destroy (surface->wl_subsurface);
13851378

1386-
if (surface->subsurface_branch_node)
1387-
{
1388-
g_node_children_foreach (surface->subsurface_branch_node,
1389-
G_TRAVERSE_NON_LEAVES,
1390-
unlink_note,
1391-
NULL);
1392-
g_clear_pointer (&surface->subsurface_branch_node, g_node_destroy);
1393-
}
1379+
g_clear_pointer (&surface->subsurface_branch_node, g_node_destroy);
13941380

13951381
g_hash_table_destroy (surface->shortcut_inhibited_seats);
13961382

0 commit comments

Comments
 (0)