Don't cache objects that return NULL when their state set is queried
authorMike Gorse <mgorse@novell.com>
Mon, 6 Feb 2012 22:35:43 +0000 (16:35 -0600)
committerMike Gorse <mgorse@novell.com>
Mon, 6 Feb 2012 22:35:43 +0000 (16:35 -0600)
If atk_object_ref_state_set returns NULL, then perhaps the object is
going away or not yet initialized, so caching it may not be a good idea.
Also stops some warnings.

atk-adaptor/accessible-cache.c

index 943a320..20796d5 100644 (file)
@@ -281,7 +281,7 @@ add_pending_items (gpointer data)
       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))
         {
          g_queue_push_tail (to_add, current);
           if (!spi_cache_in (cache, G_OBJECT (current)) &&
@@ -292,7 +292,8 @@ add_pending_items (gpointer data)
             }
         }
 
-      g_object_unref (set);
+      if (set)
+        g_object_unref (set);
     }
 
   while (!g_queue_is_empty (to_add))