From 19a03c1c2df7e510d3fa1b25eec7840cc5816dfe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Thu, 25 Jul 2019 01:02:34 +0200
Subject: [PATCH 13/28] cally/stage: Set the keyfocus to NULL if the stage is
focused
By definition when the key focus is set to NULL we assume that the stage has it,
so in such case avoid keeping track of the stage pointer and setting a weak ref
on it, as it might only cause double-free errors during the stage disposition,
that would lead (via atk) to a cally stage disposition as well.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/682
---
clutter/clutter/cally/cally-stage.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clutter/clutter/cally/cally-stage.c b/clutter/clutter/cally/cally-stage.c
index 7c100aabf..5638c1bb1 100644
--- a/clutter/clutter/cally/cally-stage.c
+++ b/clutter/clutter/cally/cally-stage.c
@@ -101,60 +101,63 @@ cally_stage_init (CallyStage *cally_stage)
*/
AtkObject*
cally_stage_new (ClutterActor *actor)
{
GObject *object = NULL;
AtkObject *accessible = NULL;
g_return_val_if_fail (CLUTTER_IS_STAGE (actor), NULL);
object = g_object_new (CALLY_TYPE_STAGE, NULL);
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, actor);
return accessible;
}
static void
cally_stage_notify_key_focus_cb (ClutterStage *stage,
GParamSpec *pspec,
CallyStage *self)
{
ClutterActor *key_focus = NULL;
AtkObject *new = NULL;
if (self->priv->active == FALSE)
return;
key_focus = clutter_stage_get_key_focus (stage);
+ if (key_focus == CLUTTER_ACTOR (stage))
+ key_focus = NULL;
+
if (key_focus != self->priv->key_focus)
{
AtkObject *old = NULL;
if (self->priv->key_focus != NULL)
{
g_object_remove_weak_pointer (G_OBJECT (self->priv->key_focus),
(gpointer *) &self->priv->key_focus);
old = clutter_actor_get_accessible (self->priv->key_focus);
}
else
old = clutter_actor_get_accessible (CLUTTER_ACTOR (stage));
atk_object_notify_state_change (old,
ATK_STATE_FOCUSED,
FALSE);
}
/* we keep notifying the focus gain without checking previous
* key-focus to avoid some missing events due timing
*/
self->priv->key_focus = key_focus;
if (key_focus != NULL)
{
/* ensure that if the key focus goes away, the field inside
* CallyStage is reset. see bug:
*
* https://bugzilla.gnome.org/show_bug.cgi?id=692706
*
--
2.26.2