[gtk+] a11y: Refactor textcellaccessible code



commit 4340e977e4847f3f451a7e397435895afa3107f5
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Wed Mar 25 03:54:19 2015 +0100

    a11y: Refactor textcellaccessible code
    
    Compute the new text and its length in advance. This way those
    computations will not confuse us when they happen in the middle of the
    actual action.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746706

 gtk/a11y/gtktextcellaccessible.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/gtk/a11y/gtktextcellaccessible.c b/gtk/a11y/gtktextcellaccessible.c
index a5fd435..1b68c94 100644
--- a/gtk/a11y/gtktextcellaccessible.c
+++ b/gtk/a11y/gtktextcellaccessible.c
@@ -137,7 +137,7 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
   GtkTextCellAccessible *text_cell = GTK_TEXT_CELL_ACCESSIBLE (cell);
   AtkObject *obj = ATK_OBJECT (cell);
   gboolean rv = FALSE;
-  gint temp_length;
+  gint temp_length, text_length;
   gchar *text;
   GtkCellRenderer *renderer;
 
@@ -149,6 +149,10 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
   g_object_get (renderer, "text", &text, NULL);
   g_object_unref (renderer);
 
+  if (text == NULL)
+    text = g_strdup ("");
+  text_length = g_utf8_strlen (text, -1);
+
   if (text_cell->priv->cell_text)
     {
       if (text == NULL || g_strcmp0 (text_cell->priv->cell_text, text) != 0)
@@ -169,16 +173,8 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
 
   if (rv)
     {
-      if (text == NULL)
-        {
-          text_cell->priv->cell_text = g_strdup ("");
-          text_cell->priv->cell_length = 0;
-        }
-      else
-        {
-          text_cell->priv->cell_text = g_strdup (text);
-          text_cell->priv->cell_length = g_utf8_strlen (text, -1);
-        }
+      text_cell->priv->cell_text = g_strdup (text);
+      text_cell->priv->cell_length = text_length;
     }
 
   g_free (text);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]