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.
static void
spi_cache_init (SpiCache * cache)
{
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 ();
cache->objects = g_hash_table_new (g_direct_hash, g_direct_equal);
cache->add_traversal = g_queue_new ();
gboolean
spi_cache_in (SpiCache * cache, GObject * object)
{
gboolean
spi_cache_in (SpiCache * cache, GObject * object)
{
+ if (!cache)
+ return FALSE;
+
if (g_hash_table_lookup_extended (cache->objects,
object,
NULL,
if (g_hash_table_lookup_extended (cache->objects,
object,
NULL,
+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);
+ }
+}
+
DBusError error;
AtkObject *root;
gboolean load_bridge;
DBusError error;
AtkObject *root;
gboolean load_bridge;
- DRoutePath *treepath, *accpath;
load_bridge = check_envvar ();
if (inited && !load_bridge)
load_bridge = check_envvar ();
if (inited && !load_bridge)
*/
spi_global_register = g_object_new (SPI_REGISTER_TYPE, NULL);
spi_global_leasing = g_object_new (SPI_LEASING_TYPE, NULL);
*/
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 ();
/* 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,
accpath = droute_add_many (spi_global_app_data->droute,
"/org/a11y/atspi/accessible",
NULL,
/* Register all interfaces with droute and set up application accessible db */
/* 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);
spi_initialize_accessible (accpath);
spi_initialize_application (accpath);
spi_initialize_action (accpath);
/* Register methods to send D-Bus signals on certain ATK events */
if (clients)
/* Register methods to send D-Bus signals on certain ATK events */
if (clients)
- spi_atk_register_event_listeners ();
/* 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);
/* 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);
- spi_atk_register_event_listeners ();
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);
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);