Fix issue where we would attempt to reference null objects
[platform/core/uifw/at-spi2-atk.git] / atk-adaptor / event.c
index 3ba1ba8..23133cb 100644 (file)
@@ -46,31 +46,36 @@ static gint atk_bridge_focus_tracker_id;
 
 /*---------------------------------------------------------------------------*/
 
+typedef struct _SpiReentrantCallClosure 
+{
+  GMainLoop   *loop;
+  DBusMessage *reply;
+} SpiReentrantCallClosure;
+
 static void
 set_reply (DBusPendingCall * pending, void *user_data)
 {
-  void **replyptr = (void **) user_data;
+  SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data; 
 
-  *replyptr = dbus_pending_call_steal_reply (pending);
+  closure->reply = dbus_pending_call_steal_reply (pending);
+  g_main_loop_quit (closure->loop);
 }
 
 static DBusMessage *
 send_and_allow_reentry (DBusConnection * bus, DBusMessage * message)
 {
   DBusPendingCall *pending;
-  DBusMessage *reply = NULL;
+  SpiReentrantCallClosure closure;
 
   if (!dbus_connection_send_with_reply (bus, message, &pending, -1))
-    {
       return NULL;
-    }
-  dbus_pending_call_set_notify (pending, set_reply, (void *) &reply, NULL);
-  while (!reply)
-    {
-      if (!dbus_connection_read_write_dispatch (bus, -1))
-        return NULL;
-    }
-  return reply;
+  dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
+  closure.loop = g_main_loop_new (NULL, FALSE);
+
+  g_main_loop_run  (closure.loop);
+  
+  g_main_loop_unref (closure.loop);
+  return closure.reply;
 }
 
 /*---------------------------------------------------------------------------*/
@@ -346,7 +351,7 @@ focus_tracker (AtkObject * accessible)
 
 /*---------------------------------------------------------------------------*/
 
-#define PCHANGE "property_change"
+#define PCHANGE "PropertyChange"
 
 /* 
  * This handler handles the following ATK signals and
@@ -385,21 +390,27 @@ property_event_listener (GSignalInvocationHint * signal_hint,
         emit_event (accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0,
                     DBUS_TYPE_STRING_AS_STRING, s1, append_basic);
     }
-  if (strcmp (pname, "accessible-description") == 0)
+  else if (strcmp (pname, "accessible-description") == 0)
     {
       s1 = atk_object_get_description (accessible);
       if (s1 != NULL)
         emit_event (accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0,
                     DBUS_TYPE_STRING_AS_STRING, s1, append_basic);
     }
-  if (strcmp (pname, "accessible-parent") == 0)
+  else if (strcmp (pname, "accessible-parent") == 0)
     {
       otemp = atk_object_get_parent (accessible);
       if (otemp != NULL)
         emit_event (accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0,
                     "(so)", otemp, append_object);
     }
-  if (strcmp (pname, "accessible-table-summary") == 0)
+  else if (strcmp (pname, "accessible-role") == 0)
+    {
+      dbus_uint32_t role = atk_object_get_role (accessible);
+      emit_event (accessible, ITF_EVENT_OBJECT, PCHANGE, pname, 0, 0,
+                    DBUS_TYPE_UINT32_AS_STRING, role, append_basic);
+    }
+  else if (strcmp (pname, "accessible-table-summary") == 0)
     {
       otemp = atk_table_get_summary (ATK_TABLE (accessible));
       if (otemp != NULL)
@@ -591,7 +602,6 @@ active_descendant_event_listener (GSignalInvocationHint * signal_hint,
   AtkObject *child;
   GSignalQuery signal_query;
   const gchar *name, *minor;
-  gchar *s;
   gint detail1;
 
   g_signal_query (signal_hint->signal_id, &signal_query);
@@ -606,7 +616,6 @@ active_descendant_event_listener (GSignalInvocationHint * signal_hint,
 
   emit_event (accessible, ITF_EVENT_OBJECT, name, "", detail1, 0,
               "(so)", child, append_object);
-  g_free (s);
   return TRUE;
 }
 
@@ -735,7 +744,7 @@ children_changed_event_listener (GSignalInvocationHint * signal_hint,
   const gchar *name, *minor;
   gint detail1, detail2 = 0;
 
-  AtkObject *accessible, *ao;
+  AtkObject *accessible, *ao=NULL;
   gpointer child;
 
   g_signal_query (signal_hint->signal_id, &signal_query);