|
|
18be8f |
From 96404287bc4269dea7b037e7b178e54ebf616d47 Mon Sep 17 00:00:00 2001
|
|
|
18be8f |
From: Daniel van Vugt <daniel.van.vugt@canonical.com>
|
|
|
18be8f |
Date: Tue, 24 Nov 2020 17:34:08 +0800
|
|
|
18be8f |
Subject: [PATCH] st-bin: Disallow st_bin_set_child with already-parented
|
|
|
18be8f |
children
|
|
|
18be8f |
|
|
|
18be8f |
Not checking for this would result in `clutter_actor_add_child`
|
|
|
18be8f |
failing, but StBin keeping a copy in `priv->child`. So later on,
|
|
|
18be8f |
`st_bin_remove` would never be called on it and this assertion
|
|
|
18be8f |
would fail and crash the whole shell:
|
|
|
18be8f |
|
|
|
18be8f |
```
|
|
|
18be8f |
static void
|
|
|
18be8f |
st_bin_destroy (ClutterActor *actor)
|
|
|
18be8f |
{
|
|
|
18be8f |
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (actor));
|
|
|
18be8f |
|
|
|
18be8f |
if (priv->child)
|
|
|
18be8f |
clutter_actor_destroy (priv->child);
|
|
|
18be8f |
g_assert (priv->child == NULL);
|
|
|
18be8f |
|
|
|
18be8f |
```
|
|
|
18be8f |
|
|
|
18be8f |
By disallowing spurious `st_bin_set_child` calls we now prevent StBin
|
|
|
18be8f |
from entering such a corrupt state and the above assertion won't fail
|
|
|
18be8f |
anymore.
|
|
|
18be8f |
|
|
|
18be8f |
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1507>
|
|
|
18be8f |
---
|
|
|
18be8f |
src/st/st-bin.c | 13 +++++++++++++
|
|
|
18be8f |
1 file changed, 13 insertions(+)
|
|
|
18be8f |
|
|
|
18be8f |
diff --git a/src/st/st-bin.c b/src/st/st-bin.c
|
|
|
18be8f |
index f013909e8..7959a4e95 100644
|
|
|
18be8f |
--- a/src/st/st-bin.c
|
|
|
18be8f |
+++ b/src/st/st-bin.c
|
|
|
18be8f |
@@ -434,6 +434,19 @@ st_bin_set_child (StBin *bin,
|
|
|
18be8f |
if (priv->child == child)
|
|
|
18be8f |
return;
|
|
|
18be8f |
|
|
|
18be8f |
+ if (child)
|
|
|
18be8f |
+ {
|
|
|
18be8f |
+ ClutterActor *parent = clutter_actor_get_parent (child);
|
|
|
18be8f |
+
|
|
|
18be8f |
+ if (parent)
|
|
|
18be8f |
+ {
|
|
|
18be8f |
+ g_warning ("%s: The provided 'child' actor %p already has a "
|
|
|
18be8f |
+ "(different) parent %p and can't be made a child of %p.",
|
|
|
18be8f |
+ G_STRFUNC, child, parent, bin);
|
|
|
18be8f |
+ return;
|
|
|
18be8f |
+ }
|
|
|
18be8f |
+ }
|
|
|
18be8f |
+
|
|
|
18be8f |
if (priv->child)
|
|
|
18be8f |
clutter_actor_remove_child (CLUTTER_ACTOR (bin), priv->child);
|
|
|
18be8f |
|
|
|
18be8f |
--
|
|
|
18be8f |
2.38.1
|
|
|
18be8f |
|