[at-spi2-atk] Have DoAction send the reply message *before* invoking atk



commit a110d6bf5aac4a11541521c568d9a8f85aecca05
Author: Mike Gorse <mgorse novell com>
Date:   Mon Mar 5 17:20:19 2012 -0600

    Have DoAction send the reply message *before* invoking atk
    
    In the past, a gtk button's do_action handler added an idle to invoke
    the button and then returned, but now the idle has been removed, and the
    do_action call activates the button directly, meaning that, if the
    button invokes a dialogue, then atk_action_do_action will not return
    until the dialog closes. So, to be safe, we need to send a reply before
    invoking atk. This means that atk's return value gets ignored, although
    it was somewhat meaningless in gtk's case anyhow. This required that
    droute's behavior be changed so that, if a handler does not return a
    message, droute will now assume that the handler already sent a reply,
    rather than synthesizing a default empty reply. Thus, handlers are now
    required to return a value DBusMessage.
    
    Perhaps the API should really be asynchronous, with a callback to be
    invoked when the action finishes.

 atk-adaptor/adaptors/action-adaptor.c |    8 +++++---
 droute/droute.c                       |   15 +++++++--------
 2 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/atk-adaptor/adaptors/action-adaptor.c b/atk-adaptor/adaptors/action-adaptor.c
index 08e3a2c..fd04faa 100644
--- a/atk-adaptor/adaptors/action-adaptor.c
+++ b/atk-adaptor/adaptors/action-adaptor.c
@@ -180,7 +180,7 @@ impl_DoAction (DBusConnection * bus, DBusMessage * message, void *user_data)
   AtkAction *action = (AtkAction *) user_data;
   DBusError error;
   dbus_int32_t index;
-  dbus_bool_t rv;
+  dbus_bool_t rv = TRUE;
   DBusMessage *reply;
 
   g_return_val_if_fail (ATK_IS_ACTION (user_data),
@@ -191,14 +191,16 @@ impl_DoAction (DBusConnection * bus, DBusMessage * message, void *user_data)
     {
       return droute_invalid_arguments_error (message);
     }
-  rv = atk_action_do_action (action, index);
   reply = dbus_message_new_method_return (message);
   if (reply)
     {
       dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
                                 DBUS_TYPE_INVALID);
     }
-  return reply;
+  dbus_connection_send (bus, reply, NULL);
+  dbus_message_unref (reply);
+  atk_action_do_action (action, index);
+  return NULL;
 }
 
 DRouteMethod methods[] = {
diff --git a/droute/droute.c b/droute/droute.c
index 9212e4d..1567fc7 100644
--- a/droute/droute.c
+++ b/droute/droute.c
@@ -537,16 +537,15 @@ handle_other (DBusConnection *bus,
         else
             reply = (func) (bus, message, datum);
 
-        if (!reply)
+        /* All D-Bus method calls must have a reply.
+         * If one is not provided presume that the caller has already
+         * sent one.
+         */
+        if (reply)
           {
-            /* All D-Bus method calls must have a reply.
-             * If one is not provided presume that the call has a void
-             * return and no error has occured.
-             */
-            reply = dbus_message_new_method_return (message);
+            dbus_connection_send (bus, reply, NULL);
+            dbus_message_unref (reply);
           }
-        dbus_connection_send (bus, reply, NULL);
-        dbus_message_unref (reply);
         result = DBUS_HANDLER_RESULT_HANDLED;
       }
 



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