From e7511dd4695a0b817e439743d2263275814de72e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 7 Feb 2012 11:36:27 +0000 Subject: [PATCH] text: Avoid changing the contents when possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An editable ClutterText will reset the selection and cursor whenever the contents are changed — even if those contents are the same. As this may confuse the user, we should check if we're setting the exact same string, and bail out if necessary. --- clutter/clutter-text.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 0d18aef4e..5f72367fc 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -4742,6 +4742,16 @@ clutter_text_set_text (ClutterText *self, { g_return_if_fail (CLUTTER_IS_TEXT (self)); + /* if the text is editable (i.e. there is not markup flag to reset) then + * changing the contents will result in selection and cursor changes that + * we should avoid + */ + if (self->priv->editable) + { + if (strcmp (clutter_text_buffer_get_text (get_buffer (self)), text) == 0) + return; + } + clutter_text_set_use_markup_internal (self, FALSE); clutter_text_buffer_set_text (get_buffer (self), text, -1); }