X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=atspi%2Fatspi-misc.c;h=e102c9bfd7477873980e0c0c8581e4ed1fd36083;hb=refs%2Fchanges%2F39%2F173339%2F2;hp=679e0dad40113ec45031b6535f654366ca45aa4f;hpb=a2cf051f4ea9a8f2975ef42cc0566ac3bbee4b3f;p=platform%2Fupstream%2Fat-spi2-core.git diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c index 679e0da..e102c9b 100644 --- a/atspi/atspi-misc.c +++ b/atspi/atspi-misc.c @@ -110,7 +110,7 @@ _atspi_get_iface_num (const char *iface) GHashTable * _atspi_get_live_refs (void) { - if (!live_refs) + if (!live_refs) { live_refs = g_hash_table_new (g_direct_hash, g_direct_equal); } @@ -179,6 +179,7 @@ handle_get_bus_address (DBusPendingCall *pending, void *user_data) DBusMessage *message; const char *address; DBusPendingCall *new_pending; + dbus_bool_t result; if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN) { @@ -215,9 +216,9 @@ handle_get_bus_address (DBusPendingCall *pending, void *user_data) "/org/a11y/atspi/cache", atspi_interface_cache, "GetItems"); - dbus_connection_send_with_reply (app->bus, message, &new_pending, 2000); + result = dbus_connection_send_with_reply (app->bus, message, &new_pending, 2000); dbus_message_unref (message); - if (!new_pending) + if (!result || !new_pending) return; dbus_pending_call_set_notify (new_pending, handle_get_items, app, NULL); } @@ -229,6 +230,7 @@ get_application (const char *bus_name) char *bus_name_dup; DBusMessage *message; DBusPendingCall *pending = NULL; + dbus_bool_t result; if (!app_hash) { @@ -249,9 +251,9 @@ get_application (const char *bus_name) message = dbus_message_new_method_call (bus_name, atspi_path_root, atspi_interface_application, "GetApplicationBusAddress"); - dbus_connection_send_with_reply (app->bus, message, &pending, 2000); + result = dbus_connection_send_with_reply (app->bus, message, &pending, 2000); dbus_message_unref (message); - if (!pending) + if (!result || !pending) { g_hash_table_remove (app_hash, bus_name_dup); return NULL; @@ -260,7 +262,7 @@ get_application (const char *bus_name) return app; } -static AtspiAccessible * +AtspiAccessible * ref_accessible (const char *app_name, const char *path) { AtspiApplication *app; @@ -637,7 +639,7 @@ _atspi_dbus_return_hyperlink_from_message (DBusMessage *message) DBusMessageIter iter; AtspiHyperlink *retval = NULL; const char *signature; - + if (!message) return NULL; @@ -850,7 +852,7 @@ spi_display_name (void) * * Connects to the accessibility registry and initializes the SPI. * - * Returns: 0 on success, 1 if already initialized, or an integer error code. + * Returns: 0 on success, 1 if already initialized, or an integer error code. **/ int atspi_init (void) @@ -870,7 +872,8 @@ atspi_init (void) bus = atspi_get_a11y_bus (); if (!bus) return 2; - dbus_bus_register (bus, NULL); + if (!dbus_bus_register (bus, NULL)) + return 2; atspi_dbus_connection_setup_with_g_main(bus, g_main_context_default()); dbus_connection_add_filter (bus, atspi_dbus_filter, NULL, NULL); match = g_strdup_printf ("type='signal',interface='%s',member='AddAccessible'", atspi_interface_cache); @@ -947,7 +950,7 @@ atspi_event_quit (void) /** * atspi_exit: * - * Disconnects from #AtspiRegistry instances and releases + * Disconnects from #AtspiRegistry instances and releases * any floating resources. Call only once at exit. * * Returns: 0 if there were no leaks, otherwise other integer values. @@ -999,6 +1002,7 @@ check_for_hang (DBusMessage *message, DBusError *error, DBusConnection *bus, con DBusMessage *message; gchar *bus_name_dup; DBusPendingCall *pending = NULL; + dbus_bool_t result; for (l = hung_processes; l; l = l->next) if (!strcmp (l->data, bus_name)) return; @@ -1007,9 +1011,9 @@ check_for_hang (DBusMessage *message, DBusError *error, DBusConnection *bus, con "Ping"); if (!message) return; - dbus_connection_send_with_reply (bus, message, &pending, -1); + result = dbus_connection_send_with_reply (bus, message, &pending, -1); dbus_message_unref (message); - if (!pending) + if (!result || !pending) return; bus_name_dup = g_strdup (bus_name); hung_processes = g_slist_append (hung_processes, bus_name_dup); @@ -1106,9 +1110,11 @@ _atspi_dbus_call_partial (gpointer obj, const char *type, ...) { va_list args; - + DBusMessage * result; va_start (args, type); - return _atspi_dbus_call_partial_va (obj, interface, method, error, type, args); + result = _atspi_dbus_call_partial_va (obj, interface, method, error, type, args); + va_end (args); + return result; } @@ -1122,9 +1128,9 @@ _atspi_dbus_call_partial_va (gpointer obj, { AtspiObject *aobj = ATSPI_OBJECT (obj); DBusError err; - DBusMessage *msg = NULL, *reply = NULL; - DBusMessageIter iter; - const char *p; + DBusMessage *msg = NULL, *reply = NULL; + DBusMessageIter iter; + const char *p; dbus_error_init (&err); @@ -1149,11 +1155,13 @@ out: process_deferred_messages (); if (dbus_error_is_set (&err)) { - /* TODO: Set gerror */ + g_set_error_literal(error, ATSPI_ERROR, ATSPI_ERROR_IPC, err.message); dbus_error_free (&err); + if (reply) + dbus_message_unref(reply); + return NULL; } - - if (reply && dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) + else if (reply && dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { const char *err_str = NULL; dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &err_str, DBUS_TYPE_INVALID); @@ -1162,7 +1170,6 @@ out: dbus_message_unref (reply); return NULL; } - return reply; } @@ -1451,7 +1458,7 @@ get_accessibility_bus_address_x11 (void) g_warning ("Could not open X display"); return NULL; } - + AT_SPI_BUS = XInternAtom (bridge_display, "AT_SPI_BUS", False); XGetWindowProperty (bridge_display, XDefaultRootWindow (bridge_display), @@ -1499,7 +1506,7 @@ get_accessibility_bus_address_dbus (void) dbus_error_free (&error); goto out; } - + { const char *tmp_address; if (!dbus_message_get_args (reply, @@ -1579,7 +1586,7 @@ atspi_get_a11y_bus (void) return NULL; } } - + /* Simulate a weak ref on the bus */ dbus_connection_set_data (a11y_bus, a11y_dbus_slot, a11y_bus, a11y_bus_free); @@ -1768,7 +1775,7 @@ _atspi_dbus_update_cache_from_dict (AtspiAccessible *accessible, DBusMessageIter g_value_set_boxed (val, &extents); } if (val) - g_hash_table_insert (cache, g_strdup (key), val); + g_hash_table_insert (cache, g_strdup (key), val); dbus_message_iter_next (&iter_dict); }