[mutter/wip/chergert/has-accessible: 1/3] clutter: avoid g_signal_emit_by_name() from ClutterActor
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/chergert/has-accessible: 1/3] clutter: avoid g_signal_emit_by_name() from ClutterActor
- Date: Sun, 23 Feb 2020 22:39:34 +0000 (UTC)
commit 400e61dd6322e0fcde94f4f1dfbaccd700a34866
Author: Christian Hergert <chergert redhat com>
Date: Sun Feb 23 12:30:56 2020 -0800
clutter: avoid g_signal_emit_by_name() from ClutterActor
g_signal_emit_by_name() is used to emit signals on ClutterContainer when
actors are removed or added. It happens to do various interface lookups
which are a bit unneccessary and can allocate memory.
Simply using emission wrappers makes all of that go away.
clutter/clutter/clutter-actor.c | 4 ++--
clutter/clutter/clutter-container.c | 20 ++++++++++++++++++++
clutter/clutter/clutter-container.h | 6 ++++++
3 files changed, 28 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 4979c9dcd..6624ae406 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -4582,7 +4582,7 @@ clutter_actor_remove_child_internal (ClutterActor *self,
/* we need to emit the signal before dropping the reference */
if (emit_actor_removed)
- g_signal_emit_by_name (self, "actor-removed", child);
+ clutter_container_emit_actor_removed (CLUTTER_CONTAINER (self), child);
if (notify_first_last)
{
@@ -13226,7 +13226,7 @@ clutter_actor_add_child_internal (ClutterActor *self,
}
if (emit_actor_added)
- g_signal_emit_by_name (self, "actor-added", child);
+ clutter_container_emit_actor_added (CLUTTER_CONTAINER (self), child);
if (notify_first_last)
{
diff --git a/clutter/clutter/clutter-container.c b/clutter/clutter/clutter-container.c
index 587d891a7..4128482e3 100644
--- a/clutter/clutter/clutter-container.c
+++ b/clutter/clutter/clutter-container.c
@@ -1250,3 +1250,23 @@ clutter_container_child_notify (ClutterContainer *container,
child,
pspec);
}
+
+void
+clutter_container_emit_actor_added (ClutterContainer *container,
+ ClutterActor *actor)
+{
+ g_return_if_fail (CLUTTER_IS_CONTAINER (container));
+ g_return_if_fail (CLUTTER_IS_ACTOR (actor));
+
+ g_signal_emit (container, container_signals[ACTOR_ADDED], 0, actor);
+}
+
+void
+clutter_container_emit_actor_removed (ClutterContainer *container,
+ ClutterActor *actor)
+{
+ g_return_if_fail (CLUTTER_IS_CONTAINER (container));
+ g_return_if_fail (CLUTTER_IS_ACTOR (actor));
+
+ g_signal_emit (container, container_signals[ACTOR_REMOVED], 0, actor);
+}
diff --git a/clutter/clutter/clutter-container.h b/clutter/clutter/clutter-container.h
index 26b991c9c..178f751fe 100644
--- a/clutter/clutter/clutter-container.h
+++ b/clutter/clutter/clutter-container.h
@@ -175,6 +175,12 @@ CLUTTER_EXPORT
void clutter_container_child_notify (ClutterContainer *container,
ClutterActor *child,
GParamSpec *pspec);
+CLUTTER_EXPORT
+void clutter_container_emit_actor_added (ClutterContainer *container,
+ ClutterActor *actor);
+CLUTTER_EXPORT
+void clutter_container_emit_actor_removed (ClutterContainer *container,
+ ClutterActor *actor);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]