[at-spi2-core] Remove old accessible data before adding from an iter



commit 228959316fe5bbe24df76af780c1aab0b58c65ff
Author: Mike Gorse <mgorse novell com>
Date:   Thu Dec 2 03:59:42 2010 -0500

    Remove old accessible data before adding from an iter
    
    Avoid adding data for an accessible twice.  Ie, if we received an
    AddAccessible before the result of Getitems, an accessible's children
    would be included twice.

 atspi/atspi-event-listener.c |    2 ++
 atspi/atspi-misc.c           |   11 +++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/atspi/atspi-event-listener.c b/atspi/atspi-event-listener.c
index 3aa69df..58be9af 100644
--- a/atspi/atspi-event-listener.c
+++ b/atspi/atspi-event-listener.c
@@ -176,6 +176,8 @@ cache_process_children_changed (AtspiEvent *event)
 
   if (!strncmp (event->type, "object:children-changed:add", 27))
   {
+    if (g_list_find (event->source->children, child))
+      return;
     GList *new_list = g_list_insert (event->source->children, g_object_ref (child), event->detail1);
     if (new_list)
       event->source->children = new_list;
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index 0135c23..c49526a 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -369,9 +369,16 @@ add_accessible_from_iter (DBusMessageIter *iter)
 
   /* get parent */
   get_reference_from_iter (&iter_struct, &app_name, &path);
+  if (accessible->accessible_parent)
+    g_object_unref (accessible->accessible_parent);
   accessible->accessible_parent = ref_accessible (app_name, path);
 
   /* Get children */
+  while (accessible->children)
+  {
+    g_object_unref (accessible->children->data);
+    accessible->children = g_list_remove (accessible->children, accessible->children->data);
+  }
   dbus_message_iter_recurse (&iter_struct, &iter_array);
   while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
   {
@@ -388,6 +395,8 @@ add_accessible_from_iter (DBusMessageIter *iter)
   dbus_message_iter_next (&iter_struct);
 
   /* name */
+  if (accessible->name)
+    g_free (accessible->name);
   dbus_message_iter_get_basic (&iter_struct, &name);
   accessible->name = g_strdup (name);
   dbus_message_iter_next (&iter_struct);
@@ -398,6 +407,8 @@ add_accessible_from_iter (DBusMessageIter *iter)
   dbus_message_iter_next (&iter_struct);
 
   /* description */
+  if (accessible->description)
+    g_free (accessible->description);
   dbus_message_iter_get_basic (&iter_struct, &description);
   accessible->description = g_strdup (description);
   dbus_message_iter_next (&iter_struct);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]