Use g_simple_async_result_{new_,}take_error
[platform/upstream/glib.git] / gio / gdbusproxy.c
index 17e6730..98bd758 100644 (file)
@@ -1140,8 +1140,7 @@ async_init_get_name_owner_cb (GDBusConnection *connection,
             }
           else
             {
-              g_simple_async_result_set_from_error (data->simple, error);
-              g_error_free (error);
+              g_simple_async_result_take_error (data->simple, error);
               g_simple_async_result_complete_in_idle (data->simple);
               async_init_data_free (data);
               goto out;
@@ -1265,8 +1264,7 @@ async_init_start_service_by_name_cb (GDBusConnection *connection,
 
  failed:
   g_warn_if_fail (error != NULL);
-  g_simple_async_result_set_from_error (data->simple, error);
-  g_error_free (error);
+  g_simple_async_result_take_error (data->simple, error);
   g_simple_async_result_complete_in_idle (data->simple);
   async_init_data_free (data);
 }
@@ -1453,8 +1451,7 @@ get_connection_cb (GObject       *source_object,
                                           data->callback,
                                           data->user_data,
                                           NULL);
-      g_simple_async_result_set_from_error (simple, error);
-      g_error_free (error);
+      g_simple_async_result_take_error (simple, error);
       g_simple_async_result_complete_in_idle (simple);
       g_object_unref (simple);
     }
@@ -1905,7 +1902,7 @@ g_dbus_proxy_new_for_bus_sync (GBusType             bus_type,
  *
  * Gets the connection @proxy is for.
  *
- * Returns: A #GDBusConnection owned by @proxy. Do not free.
+ * Returns: (transfer none): A #GDBusConnection owned by @proxy. Do not free.
  *
  * Since: 2.26
  */
@@ -2148,9 +2145,7 @@ reply_cb (GDBusConnection *connection,
                                          &error);
   if (error != NULL)
     {
-      g_simple_async_result_set_from_error (simple,
-                                            error);
-      g_error_free (error);
+      g_simple_async_result_take_error (simple, error);
     }
   else
     {
@@ -2214,7 +2209,8 @@ get_destination_for_call (GDBusProxy *proxy)
  * @method_name: Name of method to invoke.
  * @parameters: A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
  * @flags: Flags from the #GDBusCallFlags enumeration.
- * @timeout_msec: The timeout in milliseconds or -1 to use the proxy default timeout.
+ * @timeout_msec: The timeout in milliseconds (with %G_MAXINT meaning
+ *                "infinite") or -1 to use the proxy default timeout.
  * @cancellable: A #GCancellable or %NULL.
  * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't
  * care about the result of the method invocation.
@@ -2294,8 +2290,6 @@ g_dbus_proxy_call (GDBusProxy          *proxy,
   target_method_name = was_split ? split_method_name : method_name;
   target_interface_name = was_split ? split_interface_name : proxy->priv->interface_name;
 
-  g_object_set_data_full (G_OBJECT (simple), "-gdbus-proxy-method-name", g_strdup (target_method_name), g_free);
-
   /* Warn if method is unexpected (cf. :g-interface-info) */
   if (!was_split)
     {
@@ -2359,7 +2353,6 @@ g_dbus_proxy_call_finish (GDBusProxy    *proxy,
 {
   GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
   GVariant *value;
-  const char *method_name;
 
   g_return_val_if_fail (G_IS_DBUS_PROXY (proxy), NULL);
   g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL);
@@ -2372,8 +2365,7 @@ g_dbus_proxy_call_finish (GDBusProxy    *proxy,
   if (g_simple_async_result_propagate_error (simple, error))
     goto out;
 
-  value = g_simple_async_result_get_op_res_gpointer (simple);
-  method_name = g_object_get_data (G_OBJECT (simple), "-gdbus-proxy-method-name");
+  value = g_variant_ref (g_simple_async_result_get_op_res_gpointer (simple));
 
  out:
   return value;
@@ -2385,7 +2377,8 @@ g_dbus_proxy_call_finish (GDBusProxy    *proxy,
  * @method_name: Name of method to invoke.
  * @parameters: A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.
  * @flags: Flags from the #GDBusCallFlags enumeration.
- * @timeout_msec: The timeout in milliseconds or -1 to use the proxy default timeout.
+ * @timeout_msec: The timeout in milliseconds (with %G_MAXINT meaning
+ *                "infinite") or -1 to use the proxy default timeout.
  * @cancellable: A #GCancellable or %NULL.
  * @error: Return location for error or %NULL.
  *
@@ -2474,6 +2467,7 @@ g_dbus_proxy_call_sync (GDBusProxy      *proxy,
                                G_IO_ERROR,
                                G_IO_ERROR_FAILED,
                                _("Cannot invoke method; proxy is for a well-known name without an owner and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag"));
+          ret = NULL;
           goto out;
         }
     }