summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gorse <mgorse@novell.com>2011-05-23 17:46:46 -0500
committerMike Gorse <mgorse@novell.com>2011-05-23 18:32:12 -0500
commit4cfcc3967bc4cc7d3ea9636ed9d733f0d44e6848 (patch)
treed9021bdca265eea0a03a35af6f57c8ab56182e76
parent6b2c4e89c73e6f7f0bbed667e706b47cf1da03af (diff)
downloadat-spi2-core-4cfcc3967bc4cc7d3ea9636ed9d733f0d44e6848.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.c2
-rw-r--r--atspi/atspi-misc-private.h2
-rw-r--r--atspi/atspi-misc.c11
3 files changed, 9 insertions, 6 deletions
diff --git a/atspi/atspi-accessible.c b/atspi/atspi-accessible.c
index 6aec0757..d9bdeef6 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 7540f665..8c91e83c 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 22004ce6..50121078 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);
}
/**