diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2013-05-06 15:46:25 -0700 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2013-05-17 15:30:55 +0100 |
commit | a586c23ddcef9a11f6e343b4b6848cde2df54927 (patch) | |
tree | 9ad21d235ce462755b5a14d8f8e514ebaa530015 | |
parent | 05cf212088b1224b195381942075df7d7b5f9c97 (diff) | |
download | clutter-a586c23ddcef9a11f6e343b4b6848cde2df54927.tar.gz |
cally: Use a weak pointer to hold the key focus in CallyStage
We want to avoid the pointer getting stale, and causing crashes.
https://bugzilla.gnome.org/show_bug.cgi?id=692706
(cherry picked from commit 19391a9626b087bd4df452e8699d53caa54c350f)
Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
-rw-r--r-- | clutter/cally/cally-stage.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/clutter/cally/cally-stage.c b/clutter/cally/cally-stage.c index 2b1cfd179..c95ccb0f8 100644 --- a/clutter/cally/cally-stage.c +++ b/clutter/cally/cally-stage.c @@ -139,7 +139,11 @@ cally_stage_notify_key_focus_cb (ClutterStage *stage, AtkObject *old = NULL; if (self->priv->key_focus != NULL) - old = clutter_actor_get_accessible (self->priv->key_focus); + { + 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)); @@ -154,7 +158,19 @@ cally_stage_notify_key_focus_cb (ClutterStage *stage, self->priv->key_focus = key_focus; if (key_focus != NULL) - new = clutter_actor_get_accessible (key_focus); + { + /* 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 + * + * we remove the weak pointer above. + */ + g_object_add_weak_pointer (G_OBJECT (self->priv->key_focus), + (gpointer *) &self->priv->key_focus); + + new = clutter_actor_get_accessible (key_focus); + } else new = clutter_actor_get_accessible (CLUTTER_ACTOR (stage)); |