|
|
c35f0a |
From e10d6a7994dcdd9faa913444857bbe96b32528f5 Mon Sep 17 00:00:00 2001
|
|
|
c35f0a |
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
|
|
c35f0a |
Date: Tue, 10 Sep 2019 03:34:09 +0200
|
|
|
c35f0a |
Subject: [PATCH 2/2] clutter/actor: Don't emit property changes after
|
|
|
c35f0a |
::destroy
|
|
|
c35f0a |
|
|
|
c35f0a |
Clutter actors might emit property changes in dispose, while unparenting.
|
|
|
c35f0a |
However we assume that the ::destroy signal is the last one we emit for an
|
|
|
c35f0a |
actor, and that starting from this moment the object is not valid anymore,
|
|
|
c35f0a |
and so we don't expect any signal emission from it.
|
|
|
c35f0a |
|
|
|
c35f0a |
To avoid this, freeze the object notifications on an actor during its
|
|
|
c35f0a |
disposition, just before the ::destroy signal emission.
|
|
|
c35f0a |
|
|
|
c35f0a |
Update the actor-destroy test to verify this behavior.
|
|
|
c35f0a |
|
|
|
c35f0a |
https://gitlab.gnome.org/GNOME/mutter/merge_requests/769
|
|
|
c35f0a |
(cherry picked from commit 105a3f757a31299ed4eaafa0615e1fcd0b4ffeec)
|
|
|
c35f0a |
---
|
|
|
c35f0a |
clutter/clutter/clutter-actor.c | 3 +++
|
|
|
c35f0a |
clutter/tests/conform/actor-destroy.c | 13 +++++++++++++
|
|
|
c35f0a |
2 files changed, 16 insertions(+)
|
|
|
c35f0a |
|
|
|
c35f0a |
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
|
|
|
c35f0a |
index 0e531eea52..e381352e72 100644
|
|
|
c35f0a |
--- a/clutter/clutter/clutter-actor.c
|
|
|
c35f0a |
+++ b/clutter/clutter/clutter-actor.c
|
|
|
c35f0a |
@@ -5933,6 +5933,9 @@ clutter_actor_dispose (GObject *object)
|
|
|
c35f0a |
object->ref_count,
|
|
|
c35f0a |
g_type_name (G_OBJECT_TYPE (self)));
|
|
|
c35f0a |
|
|
|
c35f0a |
+ /* Stop the emission of any property change */
|
|
|
c35f0a |
+ g_object_freeze_notify (object);
|
|
|
c35f0a |
+
|
|
|
c35f0a |
g_signal_emit (self, actor_signals[DESTROY], 0);
|
|
|
c35f0a |
|
|
|
c35f0a |
/* avoid recursing when called from clutter_actor_destroy() */
|
|
|
c35f0a |
diff --git a/clutter/tests/conform/actor-destroy.c b/clutter/tests/conform/actor-destroy.c
|
|
|
c35f0a |
index 14ad1a25c8..0f648cf6c8 100644
|
|
|
c35f0a |
--- a/clutter/tests/conform/actor-destroy.c
|
|
|
c35f0a |
+++ b/clutter/tests/conform/actor-destroy.c
|
|
|
c35f0a |
@@ -174,6 +174,16 @@ on_parent_set (ClutterActor *actor,
|
|
|
c35f0a |
*parent_set_called = TRUE;
|
|
|
c35f0a |
}
|
|
|
c35f0a |
|
|
|
c35f0a |
+static void
|
|
|
c35f0a |
+on_notify (ClutterActor *actor,
|
|
|
c35f0a |
+ ClutterActor *old_parent,
|
|
|
c35f0a |
+ gpointer data)
|
|
|
c35f0a |
+{
|
|
|
c35f0a |
+ gboolean *property_changed = data;
|
|
|
c35f0a |
+
|
|
|
c35f0a |
+ *property_changed = TRUE;
|
|
|
c35f0a |
+}
|
|
|
c35f0a |
+
|
|
|
c35f0a |
static void
|
|
|
c35f0a |
actor_destruction (void)
|
|
|
c35f0a |
{
|
|
|
c35f0a |
@@ -181,6 +191,7 @@ actor_destruction (void)
|
|
|
c35f0a |
ClutterActor *child = clutter_rectangle_new ();
|
|
|
c35f0a |
gboolean destroy_called = FALSE;
|
|
|
c35f0a |
gboolean parent_set_called = FALSE;
|
|
|
c35f0a |
+ gboolean property_changed = FALSE;
|
|
|
c35f0a |
|
|
|
c35f0a |
g_object_ref_sink (test);
|
|
|
c35f0a |
|
|
|
c35f0a |
@@ -194,6 +205,7 @@ actor_destruction (void)
|
|
|
c35f0a |
clutter_container_add_actor (CLUTTER_CONTAINER (test), child);
|
|
|
c35f0a |
g_signal_connect (child, "parent-set", G_CALLBACK (on_parent_set),
|
|
|
c35f0a |
&parent_set_called);
|
|
|
c35f0a |
+ g_signal_connect (child, "notify", G_CALLBACK (on_notify), &property_changed);
|
|
|
c35f0a |
g_signal_connect (child, "destroy", G_CALLBACK (on_destroy), &destroy_called);
|
|
|
c35f0a |
|
|
|
c35f0a |
if (g_test_verbose ())
|
|
|
c35f0a |
@@ -202,6 +214,7 @@ actor_destruction (void)
|
|
|
c35f0a |
clutter_actor_destroy (test);
|
|
|
c35f0a |
g_assert (destroy_called);
|
|
|
c35f0a |
g_assert_false (parent_set_called);
|
|
|
c35f0a |
+ g_assert_false (property_changed);
|
|
|
c35f0a |
g_assert_null (child);
|
|
|
c35f0a |
g_assert_null (test);
|
|
|
c35f0a |
}
|
|
|
c35f0a |
--
|
|
|
c35f0a |
2.28.0
|
|
|
c35f0a |
|