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
This commit is contained in:
		
				
					committed by
					
						
						Benjamin Otte
					
				
			
			
				
	
			
			
			
						parent
						
							abf3d78b57
						
					
				
				
					commit
					4340e977e4
				
			@ -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)
 | 
			
		||||
@ -168,17 +172,9 @@ gtk_text_cell_accessible_update_cache (GtkCellAccessible *cell)
 | 
			
		||||
    rv = TRUE;
 | 
			
		||||
 | 
			
		||||
  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_length = text_length;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  g_free (text);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user