* atk-adaptor/component-adaptor.c, atk-adaptor/image-adaptor.c,
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / accessible-marshaller.c
index cff97fa..30d6b33 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"
-
 /*---------------------------------------------------------------------------*/
 
 /*
@@ -40,15 +40,21 @@ spi_dbus_return_object (DBusMessage *message, AtkObject *obj, gboolean unref)
 
   path = atk_dbus_object_to_path (obj);
 
-  if (unref)
+  if (obj && unref)
     g_object_unref (obj);
 
+  if (!path)
+    path = g_strdup (SPI_DBUS_PATH_NULL);
+
   reply = dbus_message_new_method_return (message);
   if (reply)
     {
-      dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, path,
+      dbus_message_append_args (reply, DBUS_TYPE_OBJECT_PATH, &path,
                                 DBUS_TYPE_INVALID);
     }
+
+  g_free (path);
+
   return reply;
 }
 
@@ -199,15 +205,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 +241,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);