From adab87b520699892e012d601821a5aee11410125 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 10 Nov 2009 12:18:32 +0000 Subject: [PATCH] text: Dirty layout cache on text direction changes When the text direction changes we should evict the cached layouts to avoid stale entries in case the direction change produces a layout with the same size. --- clutter/clutter-text.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 04f24d5..69b1c33 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -171,6 +171,9 @@ struct _ClutterTextPrivate /* Signal handler for when the backend changes its font settings */ guint font_changed_id; + + /* Signal handler for when the :text-direction changes */ + guint direction_changed_id; }; enum @@ -428,6 +431,15 @@ clutter_text_font_changed_cb (ClutterText *text) clutter_actor_queue_relayout (CLUTTER_ACTOR (text)); } +static void +clutter_text_direction_changed_cb (GObject *gobject, + GParamSpec *pspec) +{ + clutter_text_dirty_cache (CLUTTER_TEXT (gobject)); + + /* no need to queue a relayout: set_text_direction() will do that for us */ +} + /* * clutter_text_create_layout: * @text: a #ClutterText @@ -1098,6 +1110,12 @@ clutter_text_dispose (GObject *gobject) /* get rid of the entire cache */ clutter_text_dirty_cache (self); + if (priv->direction_changed_id) + { + g_signal_handler_disconnect (self, priv->direction_changed_id); + priv->direction_changed_id = 0; + } + if (priv->font_changed_id) { g_signal_handler_disconnect (clutter_get_default_backend (), @@ -2722,6 +2740,11 @@ clutter_text_init (ClutterText *self) "font-changed", G_CALLBACK (clutter_text_font_changed_cb), self); + + priv->direction_changed_id = + g_signal_connect (self, "notify::text-direction", + G_CALLBACK (clutter_text_direction_changed_cb), + NULL); } /** -- 2.7.4