diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2023-03-03 16:47:39 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2023-03-03 18:02:22 +0000 |
commit | 9b98426e716042aa4ed0a7891b99d9898acd6178 (patch) | |
tree | a897b392cacd04ecc5c195caefa75de242b436aa | |
parent | 9820d25cf9497f8ee1f42b011a8949a94f6ba8da (diff) | |
download | gtk+-9b98426e716042aa4ed0a7891b99d9898acd6178.tar.gz |
a11y: Simplify bookkeeping while iterating accessible children
-rw-r--r-- | gtk/a11y/gtkatspicontext.c | 45 |
1 files changed, 14 insertions, 31 deletions
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; |