From: Emmanuele Bassi Date: Fri, 3 Mar 2023 16:47:39 +0000 (+0000) Subject: a11y: Simplify bookkeeping while iterating accessible children X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~6^2~4^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9b98426e716042aa4ed0a7891b99d9898acd6178;p=gtk4.git a11y: Simplify bookkeeping while iterating accessible children --- diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index e32e00f71b..d2c949daff 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -376,21 +376,15 @@ get_index_in (GtkAccessible *parent, candidate != NULL; candidate = gtk_accessible_get_next_accessible_sibling (candidate)) { + g_object_unref (candidate); + if (candidate == child) - { - g_object_unref (candidate); - return res; - } + return res; if (!gtk_accessible_should_present (candidate)) - { - g_object_unref (candidate); - continue; - } + continue; res++; - - g_object_unref (candidate); } return -1; @@ -558,25 +552,19 @@ handle_accessible_method (GDBusConnection *connection, child != NULL; child = gtk_accessible_get_next_accessible_sibling (child)) { + g_object_unref (child); + if (!gtk_accessible_should_present (child)) - { - g_object_unref (child); - continue; - } + continue; if (presentable_idx == idx) break; presentable_idx += 1; - - g_object_unref (child); } if (child != NULL) - { - context = gtk_accessible_get_at_context (child); - g_object_unref (child); - } + context = gtk_accessible_get_at_context (child); if (context == NULL) { @@ -606,11 +594,10 @@ handle_accessible_method (GDBusConnection *connection, child != NULL; child = gtk_accessible_get_next_accessible_sibling (child)) { + g_object_unref (child); + if (!gtk_accessible_should_present (child)) - { - g_object_unref (child); - continue; - } + continue; GtkATContext *context = gtk_accessible_get_at_context (child); @@ -623,7 +610,6 @@ handle_accessible_method (GDBusConnection *connection, g_variant_builder_add (&builder, "@(so)", ref); g_object_unref (context); - g_object_unref (child); } g_dbus_method_invocation_return_value (invocation, g_variant_new ("(a(so))", &builder)); @@ -1787,15 +1773,12 @@ gtk_at_spi_context_get_child_count (GtkAtSpiContext *self) child != NULL; child = gtk_accessible_get_next_accessible_sibling (child)) { + g_object_unref (child); + if (!gtk_accessible_should_present (child)) - { - g_object_unref (child); - continue; - } + continue; n_children += 1; - - g_object_unref (child); } return n_children;