X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git;a=blobdiff_plain;f=atk-adaptor%2Faccessible-cache.c;h=5065a00ebb83ccce91a6b6abc8a94e542b757d97;hp=943a3206fafc293e13432954b61f90e7f97f3379;hb=01c226b1c44a797a5ac77549c34ee0523d0b532b;hpb=85af8a25e4fa1c4a65cdbe145b70c334aac97e48 diff --git a/atk-adaptor/accessible-cache.c b/atk-adaptor/accessible-cache.c index 943a320..5065a00 100644 --- a/atk-adaptor/accessible-cache.c +++ b/atk-adaptor/accessible-cache.c @@ -55,9 +55,6 @@ add_pending_items (gpointer data); static void spi_cache_finalize (GObject * object); -static void -spi_cache_dispose (GObject * object); - /*---------------------------------------------------------------------------*/ enum @@ -79,7 +76,6 @@ static void spi_cache_class_init (SpiCacheClass * klass) 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", @@ -154,14 +150,6 @@ spi_cache_finalize (GObject * object) G_OBJECT_CLASS (spi_cache_parent_class)->finalize (object); } -static void -spi_cache_dispose (GObject * object) -{ - SpiCache *cache = SPI_CACHE (object); - - G_OBJECT_CLASS (spi_cache_parent_class)->dispose (object); -} - /*---------------------------------------------------------------------------*/ static void @@ -179,8 +167,10 @@ remove_object (GObject * source, GObject * gobj, gpointer data) g_signal_emit (cache, cache_signals [OBJECT_REMOVED], 0, gobj); g_hash_table_remove (cache->objects, gobj); } - else - g_queue_remove (cache->add_traversal, gobj); + else if (g_queue_remove (cache->add_traversal, gobj)) + { + g_object_unref (gobj); + } } static void @@ -201,9 +191,10 @@ add_object (SpiCache * cache, GObject * gobj) /*---------------------------------------------------------------------------*/ -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 @@ -224,6 +215,7 @@ recursion_check_unset () recursion_check = FALSE; g_static_mutex_unlock (&recursion_check_guard); } +#endif /* SPI_ATK_DEBUG */ /*---------------------------------------------------------------------------*/ @@ -277,12 +269,14 @@ add_pending_items (gpointer data) 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) && @@ -291,8 +285,14 @@ add_pending_items (gpointer data) 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)) @@ -320,13 +320,11 @@ child_added_listener (GSignalInvocationHint * signal_hint, const GValue * param_values, gpointer data) { SpiCache *cache = spi_global_cache; - gboolean child_needs_ref = TRUE; 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 @@ -349,16 +347,14 @@ child_added_listener (GSignalInvocationHint * signal_hint, 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 (!ATK_IS_OBJECT (child)) + if (!child) { - child = atk_object_ref_accessible_child (accessible, index); - child_needs_ref = FALSE; + g_rec_mutex_unlock (&cache_mutex); + return TRUE; } - if (child_needs_ref) - g_object_ref (child); + + g_object_ref (child); g_queue_push_tail (cache->add_traversal, child); if (cache->add_pending_idle == 0) @@ -369,7 +365,7 @@ child_added_listener (GSignalInvocationHint * signal_hint, #endif } - g_static_rec_mutex_unlock (&cache_mutex); + g_rec_mutex_unlock (&cache_mutex); return TRUE; } @@ -382,7 +378,7 @@ toplevel_added_listener (AtkObject * accessible, { 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)); @@ -410,7 +406,7 @@ toplevel_added_listener (AtkObject * accessible, #endif } - g_static_rec_mutex_unlock (&cache_mutex); + g_rec_mutex_unlock (&cache_mutex); } /*---------------------------------------------------------------------------*/ @@ -424,6 +420,9 @@ spi_cache_foreach (SpiCache * cache, GHFunc func, gpointer data) gboolean spi_cache_in (SpiCache * cache, GObject * object) { + if (!cache) + return FALSE; + if (g_hash_table_lookup_extended (cache->objects, object, NULL,