static void
spi_cache_finalize (GObject * object);
-static void
-spi_cache_dispose (GObject * object);
-
/*---------------------------------------------------------------------------*/
enum
spi_cache_parent_class = g_type_class_ref (G_TYPE_OBJECT);
object_class->finalize = spi_cache_finalize;
- object_class->dispose = spi_cache_dispose;
cache_signals [OBJECT_ADDED] = \
g_signal_new ("object-added",
add_subtree (cache, spi_global_app_data->root);
- atk_add_global_event_listener (child_added_listener,
- "Gtk:AtkObject:children-changed");
+ cache->child_added_listener = atk_add_global_event_listener (child_added_listener,
+ "Gtk:AtkObject:children-changed");
g_signal_connect (G_OBJECT (spi_global_app_data->root),
"children-changed::add",
while (!g_queue_is_empty (cache->add_traversal))
g_object_unref (G_OBJECT (g_queue_pop_head (cache->add_traversal)));
g_queue_free (cache->add_traversal);
- g_free (cache->objects);
+ g_hash_table_unref (cache->objects);
- G_OBJECT_CLASS (spi_cache_parent_class)->finalize (object);
-}
+ g_signal_handlers_disconnect_by_func (spi_global_register,
+ (GCallback) remove_object, cache);
-static void
-spi_cache_dispose (GObject * object)
-{
- SpiCache *cache = SPI_CACHE (object);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (spi_global_app_data->root),
+ (GCallback) toplevel_added_listener, NULL);
+
+ atk_remove_global_event_listener (cache->child_added_listener);
- G_OBJECT_CLASS (spi_cache_parent_class)->dispose (object);
+ G_OBJECT_CLASS (spi_cache_parent_class)->finalize (object);
}
/*---------------------------------------------------------------------------*/
g_signal_emit (cache, cache_signals [OBJECT_REMOVED], 0, gobj);
g_hash_table_remove (cache->objects, gobj);
}
+ else if (g_queue_remove (cache->add_traversal, gobj))
+ {
+ g_object_unref (gobj);
+ }
}
static void
/*---------------------------------------------------------------------------*/
-static GStaticRecMutex cache_mutex = G_STATIC_REC_MUTEX_INIT;
-static GStaticMutex recursion_check_guard = G_STATIC_MUTEX_INIT;
+static GRecMutex cache_mutex;
+#ifdef SPI_ATK_DEBUG
+static GStaticMutex recursion_check_guard = G_STATIC_MUTEX_INIT;
static gboolean recursion_check = FALSE;
static gboolean
recursion_check = FALSE;
g_static_mutex_unlock (&recursion_check_guard);
}
+#endif /* SPI_ATK_DEBUG */
/*---------------------------------------------------------------------------*/
while (!g_queue_is_empty (cache->add_traversal))
{
AtkStateSet *set;
-
+
+ /* cache->add_traversal holds a ref to current */
current = g_queue_pop_head (cache->add_traversal);
set = atk_object_ref_state_set (current);
- if (!atk_state_set_contains_state (set, ATK_STATE_TRANSIENT))
+ if (set && !atk_state_set_contains_state (set, ATK_STATE_TRANSIENT))
{
+ /* transfer the ref into to_add */
g_queue_push_tail (to_add, current);
if (!spi_cache_in (cache, G_OBJECT (current)) &&
- !atk_state_set_contains_state (set, ATK_STATE_MANAGES_DESCENDANTS))
+ !atk_state_set_contains_state (set, ATK_STATE_MANAGES_DESCENDANTS) &&
+ !atk_state_set_contains_state (set, ATK_STATE_DEFUNCT))
{
append_children (current, cache->add_traversal);
}
}
+ else
+ {
+ /* drop the ref for the removed object */
+ g_object_unref (current);
+ }
- g_object_unref (set);
+ if (set)
+ g_object_unref (set);
}
while (!g_queue_is_empty (to_add))
const GValue * param_values, gpointer data)
{
SpiCache *cache = spi_global_cache;
-
AtkObject *accessible;
- AtkObject *child;
const gchar *detail = NULL;
- g_static_rec_mutex_lock (&cache_mutex);
+ g_rec_mutex_lock (&cache_mutex);
/*
* Ensure that only accessibles already in the cache
if (detail && !strncmp (detail, "add", 3))
{
gpointer child;
- int index = g_value_get_uint (param_values + 1);
child = g_value_get_pointer (param_values + 2);
+ if (!child)
+ {
+ g_rec_mutex_unlock (&cache_mutex);
+ return TRUE;
+ }
- if (!ATK_IS_OBJECT (child))
- {
- child = atk_object_ref_accessible_child (accessible, index);
- }
g_object_ref (child);
g_queue_push_tail (cache->add_traversal, child);
#endif
}
- g_static_rec_mutex_unlock (&cache_mutex);
+ g_rec_mutex_unlock (&cache_mutex);
return TRUE;
}
{
SpiCache *cache = spi_global_cache;
- g_static_rec_mutex_lock (&cache_mutex);
+ g_rec_mutex_lock (&cache_mutex);
g_return_if_fail (ATK_IS_OBJECT (accessible));
#endif
}
- g_static_rec_mutex_unlock (&cache_mutex);
+ g_rec_mutex_unlock (&cache_mutex);
}
/*---------------------------------------------------------------------------*/
gboolean
spi_cache_in (SpiCache * cache, GObject * object)
{
+ if (!cache)
+ return FALSE;
+
if (g_hash_table_lookup_extended (cache->objects,
object,
NULL,