--- registryd/desktop.c	2007-06-05 09:16:59.000000000 +0200
+++ ../at-spi-1.20.0/registryd/desktop.c	2008-09-15 11:54:37.000000000 +0200
@@ -31,6 +31,12 @@
 #include <gdk/gdkscreen.h>
 #include <gdk/gdkx.h>
 
+#undef SPI_DESKTOP_DEBUG
+
+#ifdef SPI_DESKTOP_DEBUG
+#include <stdio.h>
+#endif
+
 /* SpiDesktop signals */
 enum {
   APPLICATION_ADDED,
@@ -49,6 +55,8 @@ typedef struct {
 } Application;
 
 static gboolean exiting = FALSE;
+static gboolean is_queueing_remove = FALSE;
+static GList *apps_queue = NULL;
 
 /* A pointer to our parent object class */
 static SpiAccessibleClass *parent_class;
@@ -193,6 +201,8 @@ impl_desktop_get_child_at_index (Portabl
   CORBA_Object retval;
   Application *app;
 
+  is_queueing_remove = TRUE;
+
   app = g_list_nth_data (desktop->applications, index);
 
   if (app)
@@ -208,6 +218,24 @@ impl_desktop_get_child_at_index (Portabl
       retval = CORBA_OBJECT_NIL;
     }
 
+  is_queueing_remove = FALSE;
+
+  /* flush queued apps */
+  if (apps_queue != NULL) 
+    {
+      GList *iter = NULL;
+#ifdef SPI_DESKTOP_DEBUG
+      fprintf (stderr, "Flushing queued applications\n");
+#endif
+
+      for (iter = apps_queue; iter; iter = g_list_next (apps_queue))
+        {
+          spi_desktop_remove_application (desktop, iter->data);
+        }
+
+      apps_queue = NULL;
+    }
+
   return (Accessibility_Accessible) retval;
 }
 
@@ -324,6 +352,15 @@ spi_desktop_remove_application (SpiDeskt
   g_return_if_fail (app_ref != CORBA_OBJECT_NIL);
   g_return_if_fail (SPI_IS_DESKTOP (desktop));
 
+  if (is_queueing_remove) {
+#ifdef SPI_DESKTOP_DEBUG
+    fprintf (stderr, "Accesing to the desktop children, postpone remove app!\n");
+#endif
+    apps_queue = g_list_append (apps_queue, app_ref);
+
+    return;
+  }
+
   CORBA_exception_init (&ev);
 
   idx = 0;
