Merge branch 'fix_next_accessible_sibling_after_refcounts' into 'main'
authorMatthias Clasen <mclasen@redhat.com>
Thu, 16 Mar 2023 21:12:20 +0000 (21:12 +0000)
committerLukáš Tyrychtr <ltyrycht@redhat.com>
Wed, 22 Mar 2023 15:34:42 +0000 (16:34 +0100)
a11y: Fix the logic in gtk_accessible_get_next_accessible_sibling which decided whether we will use the overridden sibling on the context.

See merge request GNOME/gtk!5659

gtk/gtkaccessible.c

index 873094a4745f5a5066f5aaa0ff38036c8fa21e21..dad85e2e00897997846a385584b1cfcf3dc6b5e7 100644 (file)
@@ -249,25 +249,21 @@ gtk_accessible_get_next_accessible_sibling (GtkAccessible *self)
   g_return_val_if_fail (GTK_IS_ACCESSIBLE (self), NULL);
 
   GtkATContext *context;
+  GtkAccessible *sibling = NULL;
 
   context = gtk_accessible_get_at_context (self);
-  if (context != NULL)
+  if (context != NULL && gtk_at_context_get_accessible_parent (context) != NULL)
     {
-      GtkAccessible *sibling = NULL;
-
-      if (gtk_at_context_get_accessible_parent (context) != NULL)
-        {
-          sibling = gtk_at_context_get_next_accessible_sibling (context);
-          if (sibling != NULL)
-            sibling = g_object_ref (sibling);
-        }
-
-      g_object_unref (context);
-
-      return sibling;
+      sibling = gtk_at_context_get_next_accessible_sibling (context);
+      if (sibling != NULL)
+        sibling = g_object_ref (sibling);
     }
   else
-    return GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
+    sibling = GTK_ACCESSIBLE_GET_IFACE (self)->get_next_accessible_sibling (self);
+
+  g_clear_object (&context);
+
+  return sibling;
 }
 
 /**