Commit ff7bd92b authored by Milan Crha's avatar Milan Crha

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.
parent 521fc290
...@@ -3836,6 +3836,9 @@ e_util_invoke_g_dbus_proxy_call_sync_wrapper_with_error_check (GDBusProxy *dbus_ ...@@ -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 (G_IS_DBUS_PROXY (dbus_proxy), NULL);
g_return_val_if_fail (method_name != NULL, 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, result = e_util_invoke_g_dbus_proxy_call_sync_wrapper_full (dbus_proxy, method_name, parameters,
G_DBUS_CALL_FLAGS_NONE, -1, cancellable, &error); 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_ ...@@ -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); e_util_claim_dbus_proxy_call_error (dbus_proxy, method_name, error);
g_clear_error (&error); g_clear_error (&error);
g_object_unref (dbus_proxy);
return result; return result;
} }
...@@ -3932,6 +3937,9 @@ e_util_invoke_g_dbus_proxy_call_sync_wrapper_full (GDBusProxy *dbus_proxy, ...@@ -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 ())); 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 ( g_dbus_proxy_call (
dbus_proxy, method_name, parameters, flags, timeout_msec, cancellable, dbus_proxy, method_name, parameters, flags, timeout_msec, cancellable,
sync_wrapper_result_callback, &async_result); sync_wrapper_result_callback, &async_result);
...@@ -3945,6 +3953,7 @@ e_util_invoke_g_dbus_proxy_call_sync_wrapper_full (GDBusProxy *dbus_proxy, ...@@ -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); var_result = g_dbus_proxy_call_finish (dbus_proxy, async_result, error);
g_clear_object (&async_result); g_clear_object (&async_result);
g_object_unref (dbus_proxy);
return var_result; return var_result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment