Re: Fixing TnyCamelGetSupportedSecureAuthCallback error propagation.
- From: Murray Cumming <murrayc murrayc com>
- To: Philip Van Hoof <spam pvanhoof be>
- Cc: tinymail-devel-list <tinymail-devel-list gnome org>
- Subject: Re: Fixing TnyCamelGetSupportedSecureAuthCallback error propagation.
- Date: Wed, 05 Sep 2007 09:56:38 +0200
On Tue, 2007-09-04 at 20:16 +0200, Philip Van Hoof wrote:
> On Tue, 2007-09-04 at 19:33 +0200, Murray Cumming wrote:
> > - if (callback)
> > - callback (self, TRUE /* cancelled */, NULL,
> > &err, user_data);
> > - g_error_free (err);
> > + if (callback) {
> > + /* Note: The callback must free the GError if
> > it is not NULL: */
> > + callback (self, TRUE /* cancelled */, NULL,
> > err, user_data);
> > + }
>
> No, Tinymail must free this error once the callback is finished. Not the
> callback.
Quite right. I was confusing myself. Here's an updated patch.
--
murrayc murrayc com
www.murrayc.com
www.openismus.com
Index: libtinymail-camel/tny-camel-account.c
===================================================================
--- libtinymail-camel/tny-camel-account.c (revision 2704)
+++ libtinymail-camel/tny-camel-account.c (working copy)
@@ -1772,7 +1772,7 @@
if (info->callback) {
tny_lockable_lock (info->session->priv->ui_lock);
- info->callback (info->self, info->cancelled, info->result, &info->err, info->user_data);
+ info->callback (info->self, info->cancelled, info->result, info->err, info->user_data);
tny_lockable_unlock (info->session->priv->ui_lock);
}
@@ -1837,6 +1837,7 @@
TNY_CAMEL_ACCOUNT_GET_CLASS(self)->prepare_func(self, FALSE, TRUE);
authtypes = camel_service_query_auth_types (priv->service, &ex);
+
/* Result reference */
result = tny_simple_list_new ();
iter = authtypes;
@@ -1883,6 +1884,11 @@
g_mutex_free (info->mutex);
g_cond_free (info->condition);
+ if (info->err) {
+ g_error_free (info->err);
+ info->err = NULL;
+ }
+
g_slice_free (GetSupportedAuthInfo, info);
tny_status_free(status);
@@ -1896,7 +1902,7 @@
* @self: The TnyCamelAccount on which tny_camel_account_get_supported_secure_authentication() was called.
* @cancelled: Whether the operation was cancelled.
* @auth_types: A TnyList of TnyPair objects. Each TnyPair in the list has a supported secure authentication method name as its name. This list must be freed with g_object_unref().
- * @err: A GError if an error occurred, or NULL. This must be freed with g_error_free().
+ * @err: A GError if an error occurred, or NULL.
* @user_data: The user data that was provided to tny_camel_account_get_supported_secure_authentication().
*
* The callback for tny_camel_account_get_supported_secure_authentication().
@@ -1925,12 +1931,21 @@
if (!_tny_session_check_operation (priv->session, TNY_ACCOUNT (self), &err,
TNY_ACCOUNT_ERROR, TNY_ACCOUNT_ERROR_GET_SUPPORTED_AUTH))
{
- if (callback)
- callback (self, TRUE /* cancelled */, NULL, &err, user_data);
- g_error_free (err);
+ if (callback) {
+ callback (self, TRUE /* cancelled */, NULL, err, user_data);
+ }
+
+ if (err)
+ g_error_free (err);
+
return;
}
+ if (err) {
+ g_error_free (err);
+ err = NULL;
+ }
+
info = g_slice_new (GetSupportedAuthInfo);
info->session = priv->session;
info->err = NULL;
Index: libtinymail-camel/tny-camel-account.h
===================================================================
--- libtinymail-camel/tny-camel-account.h (revision 2704)
+++ libtinymail-camel/tny-camel-account.h (working copy)
@@ -107,7 +107,7 @@
void tny_camel_account_set_online (TnyCamelAccount *self, gboolean online, TnyCamelSetOnlineCallback callback);
-typedef void (*TnyCamelGetSupportedSecureAuthCallback) (TnyCamelAccount *self, gboolean cancelled, TnyList *auth_types, GError **err, gpointer user_data);
+typedef void (*TnyCamelGetSupportedSecureAuthCallback) (TnyCamelAccount *self, gboolean cancelled, TnyList *auth_types, GError *err, gpointer user_data);
void tny_camel_account_get_supported_secure_authentication(TnyCamelAccount *self, TnyCamelGetSupportedSecureAuthCallback callback, TnyStatusCallback status_callback, gpointer user_data);
G_END_DECLS
Index: ChangeLog
===================================================================
--- ChangeLog (revision 2704)
+++ ChangeLog (working copy)
@@ -1,3 +1,13 @@
+2007-09-04 Murray Cumming <murrayc murrayc com>
+
+ * libtinymail-camel/tny-camel-account.h: Change the
+ TnyCamelGetSupportedSecureAuthCallback callback to provide a
+ GError* instead of a GError**, because it is not an output parameter.
+ * libtinymail-camel/tny-camel-account.c: (on_supauth_idle_func),
+ (tny_camel_account_get_supported_secure_authentication_async_thread
+ ), (tny_camel_account_get_supported_secure_authentication):
+ Adapt to the change, propagating GErrors up to the callback.
+
2007-09-04 Philip Van Hoof <pvanhoof gnome org>
* Fixed a problem when folder creation failed: observers where
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]