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.
This commit is contained in:
Emmanuele Bassi 2009-11-10 12:18:32 +00:00
parent f94f7692a6
commit adab87b520

View File

@ -171,6 +171,9 @@ struct _ClutterTextPrivate
/* Signal handler for when the backend changes its font settings */ /* Signal handler for when the backend changes its font settings */
guint font_changed_id; guint font_changed_id;
/* Signal handler for when the :text-direction changes */
guint direction_changed_id;
}; };
enum enum
@ -428,6 +431,15 @@ clutter_text_font_changed_cb (ClutterText *text)
clutter_actor_queue_relayout (CLUTTER_ACTOR (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: * clutter_text_create_layout:
* @text: a #ClutterText * @text: a #ClutterText
@ -1098,6 +1110,12 @@ clutter_text_dispose (GObject *gobject)
/* get rid of the entire cache */ /* get rid of the entire cache */
clutter_text_dirty_cache (self); 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) if (priv->font_changed_id)
{ {
g_signal_handler_disconnect (clutter_get_default_backend (), g_signal_handler_disconnect (clutter_get_default_backend (),
@ -2722,6 +2740,11 @@ clutter_text_init (ClutterText *self)
"font-changed", "font-changed",
G_CALLBACK (clutter_text_font_changed_cb), G_CALLBACK (clutter_text_font_changed_cb),
self); self);
priv->direction_changed_id =
g_signal_connect (self, "notify::text-direction",
G_CALLBACK (clutter_text_direction_changed_cb),
NULL);
} }
/** /**