[gnome-shell/gnome-3-36] st-bin: Disallow st_bin_set_child with already-parented children
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-36] st-bin: Disallow st_bin_set_child with already-parented children
- Date: Fri, 15 Jan 2021 17:07:49 +0000 (UTC)
commit f8afcd8b891da79dc7968455fe42e2a3eaecf6b2
Author: Daniel van Vugt <daniel van vugt canonical com>
Date: Tue Nov 24 17:34:08 2020 +0800
st-bin: Disallow st_bin_set_child with already-parented children
Not checking for this would result in `clutter_actor_add_child`
failing, but StBin keeping a copy in `priv->child`. So later on,
`st_bin_remove` would never be called on it and this assertion
would fail and crash the whole shell:
```
static void
st_bin_destroy (ClutterActor *actor)
{
StBinPrivate *priv = st_bin_get_instance_private (ST_BIN (actor));
if (priv->child)
clutter_actor_destroy (priv->child);
g_assert (priv->child == NULL);
```
By disallowing spurious `st_bin_set_child` calls we now prevent StBin
from entering such a corrupt state and the above assertion won't fail
anymore.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1507>
(cherry picked from commit 244c266c9f59f1758024deb46a0418efe23243a8)
src/st/st-bin.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/src/st/st-bin.c b/src/st/st-bin.c
index b9c17e59c7..d1fedb17a9 100644
--- a/src/st/st-bin.c
+++ b/src/st/st-bin.c
@@ -412,6 +412,19 @@ st_bin_set_child (StBin *bin,
if (priv->child == child)
return;
+ if (child)
+ {
+ ClutterActor *parent = clutter_actor_get_parent (child);
+
+ if (parent)
+ {
+ g_warning ("%s: The provided 'child' actor %p already has a "
+ "(different) parent %p and can't be made a child of %p.",
+ G_STRFUNC, child, parent, bin);
+ return;
+ }
+ }
+
if (priv->child)
clutter_actor_remove_child (CLUTTER_ACTOR (bin), priv->child);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]