- AtkObject *current, *tmp;
- GQueue *stack;
- guint i;
- gboolean recurse;
-
- if (filter (accessible))
- return;
-
- stack = g_queue_new ();
- current = g_object_ref (accessible);
- action (visited, current);
- g_queue_push_head (stack, GINT_TO_POINTER (0));
-
- /*
- * The index held on the stack is the next child node
- * that needs processing at the corresponding level in the tree.
- */
- while (!g_queue_is_empty (stack))
- {
- /* Find the next child node that needs processing */
- i = GPOINTER_TO_INT(g_queue_peek_head (stack));
- recurse = FALSE;
- while (i < atk_object_get_n_accessible_children (current) &&
- recurse == FALSE)
- {
- tmp = atk_object_ref_accessible_child (current, i);
- /* If filter function */
- if (!filter (tmp))
- {
- recurse = TRUE;
- }
- else
- {
- i++;
- g_object_unref (G_OBJECT (tmp));
- }
- }
-
- if (recurse)
- {
- /* Push onto stack */
- current = tmp;
- action (visited, current);
- g_queue_peek_head_link (stack)->data = GINT_TO_POINTER (i+1);
- g_queue_push_head (stack, GINT_TO_POINTER (0));
- }
- else
- {
- /* Pop from stack */
- tmp = current;
- current = atk_object_get_parent (current);
- g_object_unref (G_OBJECT (tmp));
- g_queue_pop_head (stack);
- }
- }
+ reg->reference_counter++;
+ /* Reference of 0 not allowed as used as direct key in hash table */
+ if (reg->reference_counter == 0)
+ reg->reference_counter++;
+ return reg->reference_counter;