X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=atk-adaptor%2Fbridge.c;h=9683e18b1fc4ee4dd82adcf2eb44d21e485085a3;hb=8a7aa1f41ba4010ffbe1bef1e3bb602cb9e4e6f3;hp=be1810cca6e80c7bce51b1f6e7ab733e49c21930;hpb=611d01e09224ab1e2b1a22516feb6a13671be059;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/atk-adaptor/bridge.c b/atk-adaptor/bridge.c index be1810c..9683e18 100644 --- a/atk-adaptor/bridge.c +++ b/atk-adaptor/bridge.c @@ -249,7 +249,9 @@ register_reply (DBusPendingCall *pending, void *user_data) dbus_message_iter_next (&iter_struct); dbus_message_iter_get_basic (&iter_struct, &obj_path); + g_free (app->desktop_name); app->desktop_name = g_strdup (app_name); + g_free (app->desktop_path); app->desktop_path = g_strdup (obj_path); } } @@ -260,7 +262,8 @@ register_reply (DBusPendingCall *pending, void *user_data) } dbus_message_unref (reply); - get_registered_event_listeners (spi_global_app_data); + if (!spi_global_app_data->events_initialized) + get_registered_event_listeners (spi_global_app_data); } static gboolean @@ -273,10 +276,13 @@ register_application (SpiBridge * app) dbus_error_init (&error); + g_free (app->desktop_name); + g_free (app->desktop_path); + /* These will be overridden when we get a reply, but in practice these defaults should always be correct */ - app->desktop_name = ATSPI_DBUS_NAME_REGISTRY; - app->desktop_path = ATSPI_DBUS_PATH_ROOT; + app->desktop_name = g_strdup (ATSPI_DBUS_NAME_REGISTRY); + app->desktop_path = g_strdup (ATSPI_DBUS_PATH_ROOT); message = dbus_message_new_method_call (SPI_DBUS_NAME_REGISTRY, ATSPI_DBUS_PATH_ROOT, @@ -289,6 +295,10 @@ register_application (SpiBridge * app) if (!dbus_connection_send_with_reply (app->bus, message, &pending, -1) || !pending) { + if (pending) + dbus_pending_call_unref (pending); + + dbus_message_unref (message); return FALSE; } @@ -339,6 +349,11 @@ deregister_application (SpiBridge * app) g_free (app->app_tmp_dir); app->app_tmp_dir = NULL; } + + g_free (app->desktop_name); + app->desktop_name = NULL; + g_free (app->desktop_path); + app->desktop_path = NULL; } /*---------------------------------------------------------------------------*/ @@ -423,6 +438,8 @@ socket_ref_state_set (AtkObject *accessible) static void socket_embed_hook (AtkSocket * socket, gchar * plug_id) { + g_return_if_fail (spi_global_register != NULL); + AtkObject *accessible = ATK_OBJECT(socket); gchar *plug_name, *plug_path; AtkObjectClass *klass; @@ -638,6 +655,7 @@ signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data) const char *interface = dbus_message_get_interface (message); const char *member = dbus_message_get_member (message); DBusHandlerResult result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + static gboolean registry_lost = FALSE; if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_SIGNAL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; @@ -667,14 +685,23 @@ signal_filter (DBusConnection *bus, DBusMessage *message, void *user_data) !g_strcmp0(member, "NameOwnerChanged")) { char *name, *old, *new; - result = DBUS_HANDLER_RESULT_HANDLED; if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &old, DBUS_TYPE_STRING, &new, DBUS_TYPE_INVALID)) { - if (*old != '\0' && *new == '\0') + if (!strcmp (name, "org.a11y.atspi.Registry")) + { + if (registry_lost && !old[0]) + { + register_application (spi_global_app_data); + registry_lost = FALSE; + } + else if (!new[0]) + registry_lost = TRUE; + } + else if (*old != '\0' && *new == '\0') spi_atk_remove_client (old); } } @@ -770,6 +797,8 @@ spi_atk_activate () return; } spi_initialize_cache (treepath); + if (spi_global_app_data->bus) + droute_path_register (treepath, spi_global_app_data->bus); } } @@ -907,6 +936,7 @@ atk_bridge_adaptor_init (gint * argc, gchar ** argv[]) /* Set up filter and match rules to catch signals */ dbus_bus_add_match (spi_global_app_data->bus, "type='signal', interface='org.a11y.atspi.Registry', sender='org.a11y.atspi.Registry'", NULL); dbus_bus_add_match (spi_global_app_data->bus, "type='signal', interface='org.a11y.atspi.DeviceEventListener', sender='org.a11y.atspi.Registry'", NULL); + dbus_bus_add_match (spi_global_app_data->bus, "type='signal', arg0='org.a11y.atspi.Registry', interface='org.freedesktop.DBus', member='NameOwnerChanged'", NULL); dbus_connection_add_filter (spi_global_app_data->bus, signal_filter, NULL, NULL); @@ -925,7 +955,8 @@ atk_bridge_adaptor_cleanup (void) GList *l; GSList *ls; - g_return_if_fail (inited); + if (!inited) + return; if (!spi_global_app_data) return; @@ -939,7 +970,9 @@ atk_bridge_adaptor_cleanup (void) { dbus_connection_remove_filter (spi_global_app_data->bus, signal_filter, NULL); droute_context_unregister (spi_global_app_data->droute, spi_global_app_data->bus); + dbus_connection_close (spi_global_app_data->bus); dbus_connection_unref (spi_global_app_data->bus); + spi_global_app_data->bus = NULL; } for (l = spi_global_app_data->direct_connections; l; l = l->next) @@ -950,18 +983,20 @@ atk_bridge_adaptor_cleanup (void) droute_context_unregister (spi_global_app_data->droute, connection); droute_unintercept_dbus (connection); + dbus_connection_close (connection); dbus_connection_unref (connection); } g_list_free (spi_global_app_data->direct_connections); + spi_global_app_data->direct_connections = NULL; for (ls = clients; ls; ls = ls->next) - g_free (l->data); + g_free (ls->data); g_slist_free (clients); clients = NULL; - g_object_unref (spi_global_cache); - g_object_unref (spi_global_leasing); - g_object_unref (spi_global_register); + g_clear_object (&spi_global_cache); + g_clear_object (&spi_global_leasing); + g_clear_object (&spi_global_register); if (spi_global_app_data->main_context) g_main_context_unref (spi_global_app_data->main_context);