2009-02-10 Mark Doffman <mark.doffman@codethink.co.uk>
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / accessible-marshaller.c
index cff97fa..6e9de23 100644 (file)
  * Boston, MA 02111-1307, USA.
  */
 
+#include "spi-common/spi-dbus.h"
+
 #include "accessible-register.h"
 #include "accessible-marshaller.h"
 
-#include "spi-common/spi-dbus.h"
-
 /*---------------------------------------------------------------------------*/
 
 /*
@@ -199,15 +199,24 @@ spi_atk_append_accessible(AtkObject *obj, gpointer iter)
       parent = atk_object_get_parent(obj);
       if (parent == NULL)
         {
-          path_parent = g_strdup("/");
+          path_parent = atk_dbus_desktop_object_path ();
         }
       else
         {
           path_parent = atk_dbus_object_to_path (parent);
           if (!path_parent)
             {
-              g_critical ("AT-SPI: Object registered without registering parent");
-              path_parent = g_strdup("/");
+              /* This should only happen if a widget is re-parented to
+               * an AtkObject that has not been registered and is then
+               * updated. Ideally objects would be de-registered when
+               * they are removed from a registered tree object, but
+               * this would invalidate a huge amount of cache when
+               * re-parenting.
+               */
+#if SPI_ATK_DEBUG
+              g_warning ("AT-SPI: Registered accessible marshalled when parent not registered");
+#endif
+              path_parent = atk_dbus_desktop_object_path ();
             }
         }
       dbus_message_iter_append_basic (&iter_struct, DBUS_TYPE_OBJECT_PATH, &path_parent);
@@ -226,16 +235,12 @@ spi_atk_append_accessible(AtkObject *obj, gpointer iter)
 
               child = atk_object_ref_accessible_child (obj, i);
               child_path = atk_dbus_object_to_path (child);
-              g_object_unref(G_OBJECT(child));
-              if (G_LIKELY (child_path))
+              if (child_path)
                 {
                   dbus_message_iter_append_basic (&iter_sub_array, DBUS_TYPE_OBJECT_PATH, &child_path);
-                }
-              else
-                {
-                  g_critical ("AT-SPI: Child object exists in accessible tree but has not been registered");
                   g_free (child_path);
                 }
+              g_object_unref(G_OBJECT(child));
             }
         }
       dbus_message_iter_close_container (&iter_struct, &iter_sub_array);