[gtk/matthiasc/for-master] a11y: Fix handling of LABELLED_BY relation



commit a8baee342c943aa77ad03035e70de5ebd9906ce7
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 20 21:27:39 2020 -0400

    a11y: Fix handling of LABELLED_BY relation
    
    There were several places where we were confusing
    GList and GSList and list->data and list->next, causing
    a crash in the accessible name computation for buttons
    with mnemonic labels.

 gtk/gtkatcontext.c |  2 +-
 gtk/gtkwidget.c    | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkatcontext.c b/gtk/gtkatcontext.c
index 8a62e2821d..dd771bc10c 100644
--- a/gtk/gtkatcontext.c
+++ b/gtk/gtkatcontext.c
@@ -760,7 +760,7 @@ gtk_at_context_get_name_accumulate (GtkATContext *self,
 
       GList *list = gtk_reference_list_accessible_value_get (value);
 
-      for (GList *l = list; l != NULL; l = l->data)
+      for (GList *l = list; l != NULL; l = l->next)
         {
           GtkAccessible *rel = GTK_ACCESSIBLE (l->data);
           GtkATContext *rel_context = gtk_accessible_get_at_context (rel);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 014772acb2..f51b32bbb5 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8973,6 +8973,7 @@ gtk_widget_add_mnemonic_label (GtkWidget *widget,
                                GtkWidget *label)
 {
   GSList *old_list, *new_list;
+  GList *list;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (GTK_IS_WIDGET (label));
@@ -8983,8 +8984,9 @@ gtk_widget_add_mnemonic_label (GtkWidget *widget,
   g_object_set_qdata_full (G_OBJECT (widget), quark_mnemonic_labels,
                           new_list, (GDestroyNotify) g_slist_free);
 
+  list = gtk_widget_list_mnemonic_labels (widget);
   gtk_accessible_update_relation (GTK_ACCESSIBLE (widget),
-                                  GTK_ACCESSIBLE_RELATION_LABELLED_BY, new_list,
+                                  GTK_ACCESSIBLE_RELATION_LABELLED_BY, list,
                                   -1);
 }
 
@@ -9017,15 +9019,17 @@ gtk_widget_remove_mnemonic_label (GtkWidget *widget,
 
   if (new_list != NULL && new_list->data != NULL)
     {
+      GList *list;
+
+      list = gtk_widget_list_mnemonic_labels (widget);
       gtk_accessible_update_relation (GTK_ACCESSIBLE (widget),
-                                      GTK_ACCESSIBLE_RELATION_LABELLED_BY, new_list,
+                                      GTK_ACCESSIBLE_RELATION_LABELLED_BY, list,
                                       -1);
     }
   else
     {
-      gtk_accessible_update_relation (GTK_ACCESSIBLE (widget),
-                                      GTK_ACCESSIBLE_RELATION_LABELLED_BY, NULL,
-                                      -1);
+      gtk_accessible_reset_relation (GTK_ACCESSIBLE (widget),
+                                     GTK_ACCESSIBLE_RELATION_LABELLED_BY);
     }
 }
 


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