[at-spi2-core] Enable caching on a call to atspi_accessible_set_cache_mask



commit d6bf707a6932c7506c18a98bbe18148ff8a2de30
Author: Mike Gorse <mgorse novell com>
Date:   Mon Mar 5 17:32:32 2012 -0600

    Enable caching on a call to atspi_accessible_set_cache_mask
    
    Previously, caching was always disabled unless atspi_event_main() was
    called to start a main loop, since we need to handle the case of a
    simple application/script that performs an action and then sleeps rather
    than entering a main loop. In such a case, libatspi will not be able to
    detect that an event has been fired to update the cache, so caching
    should be disabled. However, an application may want to start a main
    loop through some other mechanism than by calling atspi-event_main(),
    and caching should be done in such a case. So we'll assume that, if
    atspi_accessible_set_cache_mask is called, then the application expects
    caching to work and will run a main loop one way or another. Note that
    it is possible for a script to run a main loop in some instances but not
    others, and, in such a case, if it is not using atspi_event_main(), then
    it should set caching to ATSPI_CACHE_NONE when not in a main loop and
    back to ATSPI_CACHE_DEFAULT when running a main loop.

 atspi/atspi-accessible.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 468c384..9534bae 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -25,6 +25,8 @@
 #include "atspi-private.h"
 #include <string.h>
 
+static gboolean enable_caching = FALSE;
+
 static void
 atspi_action_interface_init (AtspiAction *action)
 {
@@ -1466,6 +1468,7 @@ atspi_accessible_set_cache_mask (AtspiAccessible *accessible, AtspiCache mask)
   g_return_if_fail (accessible->parent.app != NULL);
   g_return_if_fail (accessible == accessible->parent.app->root);
   accessible->parent.app->cache = mask;
+  enable_caching = TRUE;
 }
 
 /**
@@ -1556,7 +1559,8 @@ _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
   AtspiCache result = accessible->cached_properties & mask & flag;
   if (accessible->states && atspi_state_set_contains (accessible->states, ATSPI_STATE_TRANSIENT))
     return FALSE;
-  return (result != 0 && atspi_main_loop && !atspi_no_cache);
+  return (result != 0 && (atspi_main_loop || enable_caching) &&
+          !atspi_no_cache);
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]