diff options
author | Mike Gorse <mgorse@novell.com> | 2011-05-23 17:47:03 -0500 |
---|---|---|
committer | Mike Gorse <mgorse@novell.com> | 2011-05-23 18:46:40 -0500 |
commit | dbfd0b47ebde8dffcf91567dc1d77f79fae6e605 (patch) | |
tree | 041624f660473980cd5b0383ca7b34637ca2341c | |
parent | 9371b82b63739b0b727a2783d532b84a8256f525 (diff) | |
download | at-spi2-core-dbfd0b47ebde8dffcf91567dc1d77f79fae6e605.tar.gz |
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.
-rw-r--r-- | atspi/atspi-accessible.c | 2 | ||||
-rw-r--r-- | atspi/atspi-misc-private.h | 2 | ||||
-rw-r--r-- | 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 d4663906..fd45ab49 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 80653ed4..84f1ac68 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 c353ae43..0bc99f68 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); } /** |