summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gorse <mgorse@suse.com>2012-09-13 12:55:36 -0500
committerMike Gorse <mgorse@suse.com>2012-09-13 12:55:36 -0500
commit611d01e09224ab1e2b1a22516feb6a13671be059 (patch)
tree3eb31a059f2b042c48bb89b766b2ad2766a4e87a
parent278bafc52334d22f65e1d1d56af38ebc4b4f8352 (diff)
downloadat-spi2-atk-611d01e09224ab1e2b1a22516feb6a13671be059.tar.gz
Only initialize the cache when an AT is running
If no AT is running, we shouldn't need to be maintaining the cache, so only initialize when an AT is active. Note that this change does not deinitialize the cache when an AT is no longer running. Deinitializing and setting spi_global_cache to NULL might be a good idea, but trying to keep risk to a minimum this close to 3.6.
-rw-r--r--atk-adaptor/accessible-cache.c4
-rw-r--r--atk-adaptor/bridge.c38
2 files changed, 28 insertions, 14 deletions
diff --git a/atk-adaptor/accessible-cache.c b/atk-adaptor/accessible-cache.c
index a0922e6..12bcfac 100644
--- a/atk-adaptor/accessible-cache.c
+++ b/atk-adaptor/accessible-cache.c
@@ -109,6 +109,7 @@ static void spi_cache_class_init (SpiCacheClass * klass)
static void
spi_cache_init (SpiCache * cache)
{
+g_print("dbg: init cache\n");
cache->objects = g_hash_table_new (g_direct_hash, g_direct_equal);
cache->add_traversal = g_queue_new ();
@@ -422,6 +423,9 @@ spi_cache_foreach (SpiCache * cache, GHFunc func, gpointer data)
gboolean
spi_cache_in (SpiCache * cache, GObject * object)
{
+ if (!cache)
+ return FALSE;
+
if (g_hash_table_lookup_extended (cache->objects,
object,
NULL,
diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c
index f0dc317..be1810c 100644
--- a/atk-adaptor/bridge.c
+++ b/atk-adaptor/bridge.c
@@ -752,6 +752,27 @@ check_envvar (void)
return TRUE;
}
+void
+spi_atk_activate ()
+{
+ DRoutePath *treepath;
+
+ spi_atk_register_event_listeners ();
+ if (!spi_global_cache)
+ {
+ spi_global_cache = g_object_new (SPI_CACHE_TYPE, NULL);
+ treepath = droute_add_one (spi_global_app_data->droute,
+ "/org/a11y/atspi/cache", spi_global_cache);
+
+ if (!treepath)
+ {
+ g_warning ("atk-bridge: Error in droute_add_one(). Already running?");
+ return;
+ }
+ spi_initialize_cache (treepath);
+ }
+}
+
/*
* spi_app_init
*
@@ -771,7 +792,7 @@ atk_bridge_adaptor_init (gint * argc, gchar ** argv[])
DBusError error;
AtkObject *root;
gboolean load_bridge;
- DRoutePath *treepath, *accpath;
+ DRoutePath *accpath;
load_bridge = check_envvar ();
if (inited && !load_bridge)
@@ -845,21 +866,11 @@ atk_bridge_adaptor_init (gint * argc, gchar ** argv[])
*/
spi_global_register = g_object_new (SPI_REGISTER_TYPE, NULL);
spi_global_leasing = g_object_new (SPI_LEASING_TYPE, NULL);
- spi_global_cache = g_object_new (SPI_CACHE_TYPE, NULL);
/* Register droute for routing AT-SPI messages */
spi_global_app_data->droute =
droute_new ();
- treepath = droute_add_one (spi_global_app_data->droute,
- "/org/a11y/atspi/cache", spi_global_cache);
-
- if (!treepath)
- {
- g_warning ("atk-bridge: Error in droute_add_one(). Already running?");
- return -1;
- }
-
accpath = droute_add_many (spi_global_app_data->droute,
"/org/a11y/atspi/accessible",
NULL,
@@ -870,7 +881,6 @@ atk_bridge_adaptor_init (gint * argc, gchar ** argv[])
/* Register all interfaces with droute and set up application accessible db */
- spi_initialize_cache (treepath);
spi_initialize_accessible (accpath);
spi_initialize_application (accpath);
spi_initialize_action (accpath);
@@ -892,7 +902,7 @@ atk_bridge_adaptor_init (gint * argc, gchar ** argv[])
/* Register methods to send D-Bus signals on certain ATK events */
if (clients)
- spi_atk_register_event_listeners ();
+ spi_atk_activate ();
/* Set up filter and match rules to catch signals */
dbus_bus_add_match (spi_global_app_data->bus, "type='signal', interface='org.a11y.atspi.Registry', sender='org.a11y.atspi.Registry'", NULL);
@@ -981,7 +991,7 @@ spi_atk_add_client (const char *bus_name)
return;
}
if (!clients)
- spi_atk_register_event_listeners ();
+ spi_atk_activate ();
clients = g_slist_append (clients, g_strdup (bus_name));
match = g_strdup_printf (name_match_tmpl, bus_name);
dbus_bus_add_match (spi_global_app_data->bus, match, NULL);