DBusHandlerResult _atspi_dbus_handle_event (DBusConnection *bus, DBusMessage *message, void *data);
+void remove_accessible_from_app_hash (const char *app_name, AtspiAccessible *a);
+
void
_atspi_reregister_event_listeners ();
else if (!strncmp (e.type, "object:state-changed", 20))
{
cache_process_state_changed (&e);
+ if (detail && !strncmp(detail, "defunct", 7))
+ {
+ remove_accessible_from_app_hash(sender, e.source);
+ remove_accessible_from_app_hash(sender, e.sender);
+ }
}
else if (!strncmp (e.type, "focus", 5))
{
#include <stdio.h>
#include <string.h>
+/* This value is not fixed, could be changed. */
+#define HASH_TABLE_SIZE_MAX 1000
+
static void handle_get_items (DBusPendingCall *pending, void *user_data);
static DBusConnection *bus = NULL;
a = _atspi_accessible_new (app, path);
if (!a)
return NULL;
+
+ if (g_hash_table_size (app->hash) > HASH_TABLE_SIZE_MAX)
+ {
+ g_warning ("Accessible hash table is bigger than MAX: %d\n", HASH_TABLE_SIZE_MAX);
+ g_hash_table_remove_all(app->hash);
+ }
+
g_hash_table_insert (app->hash, g_strdup (a->parent.path), g_object_ref (a));
return a;
}
return DBUS_HANDLER_RESULT_HANDLED;
}
+void
+remove_accessible_from_app_hash (const char *app_name, AtspiAccessible *a)
+{
+ AtspiApplication *app;
+
+ if (!a) return;
+
+ app = get_application (app_name);
+ if (!app) return;
+
+ if (!g_hash_table_lookup (app->hash, a->parent.path)) return;
+
+ g_hash_table_remove (app->hash, a->parent.path);
+}
+
static DBusHandlerResult
handle_name_owner_changed (DBusConnection *bus, DBusMessage *message, void *user_data)
{