[at-spi2-core] Disable caching when not in atspi_event_main



commit 4cfcc3967bc4cc7d3ea9636ed9d733f0d44e6848
Author: Mike Gorse <mgorse novell com>
Date:   Mon May 23 17:46:46 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 6aec075..d9bdeef 100644
--- a/atspi/atspi-accessible.c
+++ b/atspi/atspi-accessible.c
@@ -1401,7 +1401,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 7540f66..8c91e83 100644
--- a/atspi/atspi-misc-private.h
+++ b/atspi/atspi-misc-private.h
@@ -183,4 +183,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 22004ce..5012107 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]