[at-spi2-core/gnome-3-0] Disable caching when not in atspi_event_main



commit dbfd0b47ebde8dffcf91567dc1d77f79fae6e605
Author: Mike Gorse <mgorse novell com>
Date:   Mon May 23 17:47:03 2011 -0500

    Disable caching when not in atspi_event_main
    
    If we are not in a GLib main loop, then we will not see signals to update
    the cache, so cached data will become invalid.  Assume that, if
    atspi-event_main has not been called, then we are, for instance, in a simple
    pyatspi script without a main loop, so we should disable caching.

 atspi/atspi-accessible.c   |    2 +-
 atspi/atspi-misc-private.h |    2 ++
 atspi/atspi-misc.c         |   11 ++++++-----
 3 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index d466390..fd45ab4 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -1406,7 +1406,7 @@ _atspi_accessible_test_cache (AtspiAccessible *accessible, AtspiCache flag)
 {
   AtspiCache mask = _atspi_accessible_get_cache_mask (accessible);
   AtspiCache result = accessible->cached_properties & mask & flag;
-  return (result != 0);
+  return (result != 0 && atspi_main_loop);
 }
 
 void
diff --git a/atspi/atspi-misc-private.h b/atspi/atspi-misc-private.h
index 80653ed..84f1ac6 100644
--- a/atspi/atspi-misc-private.h
+++ b/atspi/atspi-misc-private.h
@@ -181,4 +181,6 @@ typedef enum
   ATSPI_ERROR_APPLICATION_GONE,
   ATSPI_ERROR_IPC
 } AtspiError;
+
+extern GMainLoop *atspi_main_loop;
 #endif	/* _ATSPI_MISC_PRIVATE_H_ */
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index c353ae4..0bc99f6 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -39,6 +39,8 @@ static void handle_get_items (DBusPendingCall *pending, void *user_data);
 static DBusConnection *bus = NULL;
 static GHashTable *live_refs = NULL;
 
+GMainLoop *atspi_main_loop;
+
 const char *atspi_path_dec = ATSPI_DBUS_PATH_DEC;
 const char *atspi_path_registry = ATSPI_DBUS_PATH_REGISTRY;
 const char *atspi_path_root = ATSPI_DBUS_PATH_ROOT;
@@ -859,8 +861,6 @@ atspi_init (void)
   return 0;
 }
 
-  static GMainLoop *mainloop;
-
 /**
  * atspi_event_main:
  *
@@ -873,8 +873,9 @@ atspi_init (void)
 void
 atspi_event_main (void)
 {
-  mainloop = g_main_loop_new (NULL, FALSE);
-  g_main_loop_run (mainloop);
+  atspi_main_loop = g_main_loop_new (NULL, FALSE);
+  g_main_loop_run (atspi_main_loop);
+  atspi_main_loop = NULL;
 }
 
 /**
@@ -886,7 +887,7 @@ atspi_event_main (void)
 void
 atspi_event_quit (void)
 {
-  g_main_loop_quit (mainloop);
+  g_main_loop_quit (atspi_main_loop);
 }
 
 /**



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