diff options
author | Mike Gorse <mgorse@suse.com> | 2015-06-18 20:04:31 -0500 |
---|---|---|
committer | Mike Gorse <mgorse@suse.com> | 2015-08-14 18:49:46 -0500 |
commit | b2c8c4c7230742b683db3d69a608950fede76b6c (patch) | |
tree | acea76d5c73eef71648309da4ff71d16d5d88ce6 /atspi/atspi-event-listener.c | |
parent | 2a9c0f5464ccf0b24c803c6a619f83d797362bde (diff) | |
download | at-spi2-core-b2c8c4c7230742b683db3d69a608950fede76b6c.tar.gz |
Modified cache API to include index and child count rather than children
The original cache API was problematic for QT AT-SPI because it forces
enumeration of all children, preventing lazy instantiation of objects.
The API now sends the object's index in parent and child count (or -1 if
not known / children should not be cached) rather than an array of
children.
Also made cache of children a GPtrArray rather than a GList, since it
may contain holes. If an object has not yet been instantiated for a
particular child, then its value will be set to NULL, and
atspi_accessible_get_child_at_index will make a dbus call to fetch the
child, at which point it will be cached.
https://bugzilla.gnome.org/show_bug.cgi?id=650090
Diffstat (limited to 'atspi/atspi-event-listener.c')
-rw-r--r-- | atspi/atspi-event-listener.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/atspi/atspi-event-listener.c b/atspi/atspi-event-listener.c index 292e88ba..7746ea1f 100644 --- a/atspi/atspi-event-listener.c +++ b/atspi/atspi-event-listener.c @@ -210,18 +210,24 @@ cache_process_children_changed (AtspiEvent *event) if (!strncmp (event->type, "object:children-changed:add", 27)) { - if (g_list_find (event->source->children, child)) + g_ptr_array_remove (event->source->children, child); /* just to be safe */ + if (event->detail1 < 0 || event->detail1 > event->source->children->len) + { + event->source->cached_properties &= ~ATSPI_CACHE_CHILDREN; return; - event->source->children = g_list_insert (event->source->children, - g_object_ref (child), - event->detail1); + } + /* Unfortunately, there's no g_ptr_array_insert or similar */ + g_ptr_array_add (event->source->children, NULL); + memmove (event->source->children->pdata + event->detail1 + 1, + event->source->children->pdata + event->detail1, + (event->source->children->len - event->detail1 - 1) * sizeof (gpointer)); + g_ptr_array_index (event->source->children, event->detail1) = g_object_ref (child); } - else if (g_list_find (event->source->children, child)) + else { - event->source->children = g_list_remove (event->source->children, child); + g_ptr_array_remove (event->source->children, child); if (child == child->parent.app->root) g_object_run_dispose (G_OBJECT (child->parent.app)); - g_object_unref (child); } } |