X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=atk-adaptor%2Fevent.c;h=9e6e83e1fb5e763d3985f7d45b8b5977cfac841f;hb=a16f5306aab7f9d5a8e0fe32fb75deddba175341;hp=f843f4f16686ba2022f78297d488c4ee1c6c6412;hpb=747254496ecabd11e84615295ef629959f8ad9d6;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/atk-adaptor/event.c b/atk-adaptor/event.c index f843f4f..9e6e83e 100644 --- a/atk-adaptor/event.c +++ b/atk-adaptor/event.c @@ -53,11 +53,26 @@ typedef struct _SpiReentrantCallClosure } SpiReentrantCallClosure; static void +switch_main_context (GMainContext *cnx) +{ +#ifndef DISABLE_P2P +/* This code won't work on dbus-glib earlier than 0.9.0 because of FDO#30574 */ + GList *list; + + dbus_server_setup_with_g_main (spi_global_app_data->server, cnx); + dbus_connection_setup_with_g_main (spi_global_app_data->bus, cnx); + for (list = spi_global_app_data->direct_connections; list; list = list->next) + dbus_connection_setup_with_g_main (list->data, cnx); +#endif +} + +static void set_reply (DBusPendingCall * pending, void *user_data) { SpiReentrantCallClosure* closure = (SpiReentrantCallClosure *) user_data; closure->reply = dbus_pending_call_steal_reply (pending); + switch_main_context (NULL); g_main_loop_quit (closure->loop); } @@ -66,26 +81,20 @@ send_and_allow_reentry (DBusConnection * bus, DBusMessage * message) { DBusPendingCall *pending; SpiReentrantCallClosure closure; + GMainContext *main_context; - if (!dbus_connection_send_with_reply (bus, message, &pending, -1)) - return NULL; - dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL); - closure.loop = g_main_loop_new (NULL, FALSE); + main_context = (g_getenv ("AT_SPI_CLIENT") ? NULL : + spi_global_app_data->main_context); + closure.loop = g_main_loop_new (main_context, FALSE); + switch_main_context (main_context); - /* TODO: Remove old AT_SPI_CLIENT name */ - if (getenv ("AT_SPI_CLIENT") || getenv ("AT_SPI_REENTER_G_MAIN_LOOP")) - { - g_main_loop_run (closure.loop); - } - else + if (!dbus_connection_send_with_reply (bus, message, &pending, -1)) { - closure.reply = NULL; - while (!closure.reply) - { - if (!dbus_connection_read_write_dispatch (spi_global_app_data->bus, 1000)) - return NULL; - } + switch_main_context (NULL); + return NULL; } + dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL); + g_main_loop_run (closure.loop); g_main_loop_unref (closure.loop); return closure.reply; @@ -408,7 +417,6 @@ emit_event (AtkObject *obj, */ cname = signal_name_to_dbus (major); sig = dbus_message_new_signal(path, klass, cname); - g_free(cname); dbus_message_iter_init_append(sig, &iter); @@ -423,6 +431,8 @@ emit_event (AtkObject *obj, if (g_strcmp0 (cname, "ChildrenChanged") != 0) spi_object_lease_if_needed (G_OBJECT (obj)); + + g_free(cname); } /*---------------------------------------------------------------------------*/