[evolution] Reference a GDBusProxy object in the synchronous call wrappers



commit ff7bd92b929066b27be2091dcbe5c4e739165799
Author: Milan Crha <mcrha redhat com>
Date:   Mon May 13 16:23:17 2019 +0200

    Reference a GDBusProxy object in the synchronous call wrappers
    
    ...to ensure it won't disappear under its hands before the call
    is finished. It could happen, when for example the composer is closed
    while the code is waiting for completion of the D-Bus call.

 src/e-util/e-misc-utils.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/e-util/e-misc-utils.c b/src/e-util/e-misc-utils.c
index d9585293c5..610be90907 100644
--- a/src/e-util/e-misc-utils.c
+++ b/src/e-util/e-misc-utils.c
@@ -3836,6 +3836,9 @@ e_util_invoke_g_dbus_proxy_call_sync_wrapper_with_error_check (GDBusProxy *dbus_
        g_return_val_if_fail (G_IS_DBUS_PROXY (dbus_proxy), NULL);
        g_return_val_if_fail (method_name != NULL, NULL);
 
+       /* Reference the D-Bus proxy, to not have it disappeared under its hands */
+       g_object_ref (dbus_proxy);
+
        result = e_util_invoke_g_dbus_proxy_call_sync_wrapper_full (dbus_proxy, method_name, parameters,
                G_DBUS_CALL_FLAGS_NONE, -1, cancellable, &error);
 
@@ -3845,6 +3848,8 @@ e_util_invoke_g_dbus_proxy_call_sync_wrapper_with_error_check (GDBusProxy *dbus_
        e_util_claim_dbus_proxy_call_error (dbus_proxy, method_name, error);
        g_clear_error (&error);
 
+       g_object_unref (dbus_proxy);
+
        return result;
 }
 
@@ -3932,6 +3937,9 @@ e_util_invoke_g_dbus_proxy_call_sync_wrapper_full (GDBusProxy *dbus_proxy,
 
        g_warn_if_fail (e_util_is_main_thread (g_thread_self ()));
 
+       /* Reference the D-Bus proxy, to not have it disappeared under its hands */
+       g_object_ref (dbus_proxy);
+
        g_dbus_proxy_call (
                dbus_proxy, method_name, parameters, flags, timeout_msec, cancellable,
                sync_wrapper_result_callback, &async_result);
@@ -3945,6 +3953,7 @@ e_util_invoke_g_dbus_proxy_call_sync_wrapper_full (GDBusProxy *dbus_proxy,
        var_result = g_dbus_proxy_call_finish (dbus_proxy, async_result, error);
 
        g_clear_object (&async_result);
+       g_object_unref (dbus_proxy);
 
        return var_result;
 }


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