diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-10-06 21:35:14 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-10-06 21:37:01 +0800 |
commit | 126aa2398abc1bbab0fd0cd76fda5042cc83fe76 (patch) | |
tree | a56dac4e77d7fad6901468564caa09644a1a806b | |
parent | 938505da180727fbc56b68b80851adc3cf676523 (diff) | |
download | gsoc2013-evolution-126aa2398abc1bbab0fd0cd76fda5042cc83fe76.tar.gz gsoc2013-evolution-126aa2398abc1bbab0fd0cd76fda5042cc83fe76.tar.zst gsoc2013-evolution-126aa2398abc1bbab0fd0cd76fda5042cc83fe76.zip |
Prefer g_simple_async_result_take_error().
Slightly more efficient and convenient than:
g_simple_async_result_set_from_error (simple, error);
g_error_free (error);
One less GError to copy and destroy.
-rw-r--r-- | composer/e-msg-composer.c | 9 | ||||
-rw-r--r-- | e-util/e-file-utils.c | 3 | ||||
-rw-r--r-- | mail/e-mail-folder-utils.c | 42 | ||||
-rw-r--r-- | mail/e-mail-session-utils.c | 33 | ||||
-rw-r--r-- | mail/e-mail-session.c | 18 | ||||
-rw-r--r-- | mail/e-mail-store-utils.c | 24 | ||||
-rw-r--r-- | modules/composer-autosave/e-autosave-utils.c | 21 | ||||
-rw-r--r-- | widgets/misc/e-attachment-store.c | 18 | ||||
-rw-r--r-- | widgets/misc/e-attachment.c | 15 |
9 files changed, 61 insertions, 122 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 82541d6aa7..82bca68514 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -966,15 +966,13 @@ composer_build_message_thread (GSimpleAsyncResult *simple, } if (!composer_build_message_pgp (context, cancellable, &error)) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); + g_simple_async_result_take_error (simple, error); return; } #if defined (HAVE_NSS) if (!composer_build_message_smime (context, cancellable, &error)) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); + g_simple_async_result_take_error (simple, error); return; } #endif /* HAVE_NSS */ @@ -4594,8 +4592,7 @@ composer_get_message_ready (EMsgComposer *composer, if (error != NULL) { g_warn_if_fail (message == 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 (simple); diff --git a/e-util/e-file-utils.c b/e-util/e-file-utils.c index 3f5f85488a..ebb65f460e 100644 --- a/e-util/e-file-utils.c +++ b/e-util/e-file-utils.c @@ -93,8 +93,7 @@ file_replace_contents_cb (GFile *file, context->new_etag = new_etag; else { g_warn_if_fail (new_etag == 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 (simple); diff --git a/mail/e-mail-folder-utils.c b/mail/e-mail-folder-utils.c index 77a9708e5f..fe093adb21 100644 --- a/mail/e-mail-folder-utils.c +++ b/mail/e-mail-folder-utils.c @@ -84,10 +84,8 @@ mail_folder_append_message_thread (GSimpleAsyncResult *simple, context->info, &context->message_uid, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } gboolean @@ -199,10 +197,8 @@ mail_folder_build_attachment_thread (GSimpleAsyncResult *simple, CAMEL_FOLDER (object), context->ptr_array, &context->fwd_subject, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } CamelMimePart * @@ -359,10 +355,8 @@ mail_folder_find_duplicate_messages_thread (GSimpleAsyncResult *simple, CAMEL_FOLDER (object), context->ptr_array, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } GHashTable * @@ -559,10 +553,8 @@ mail_folder_get_multiple_messages_thread (GSimpleAsyncResult *simple, CAMEL_FOLDER (object), context->ptr_array, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } GHashTable * @@ -685,10 +677,8 @@ mail_folder_remove_thread (GSimpleAsyncResult *simple, e_mail_folder_remove_sync ( CAMEL_FOLDER (object), cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } static gboolean @@ -912,10 +902,8 @@ mail_folder_remove_attachments_thread (GSimpleAsyncResult *simple, CAMEL_FOLDER (object), context->ptr_array, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } /* Helper for e_mail_folder_remove_attachments_sync() */ @@ -1128,10 +1116,8 @@ mail_folder_save_messages_thread (GSimpleAsyncResult *simple, CAMEL_FOLDER (object), context->ptr_array, context->destination, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } /* Helper for e_mail_folder_save_messages_sync() */ diff --git a/mail/e-mail-session-utils.c b/mail/e-mail-session-utils.c index 217e7e2e8e..eca58bcad0 100644 --- a/mail/e-mail-session-utils.c +++ b/mail/e-mail-session-utils.c @@ -131,10 +131,8 @@ mail_session_handle_draft_headers_thread (GSimpleAsyncResult *simple, e_mail_session_handle_draft_headers_sync ( session, context->message, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } gboolean @@ -249,10 +247,8 @@ mail_session_handle_source_headers_thread (GSimpleAsyncResult *simple, e_mail_session_handle_source_headers_sync ( session, context->message, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } gboolean @@ -426,8 +422,7 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, /* XXX This API does not allow for cancellation. */ if (!em_utils_connect_service_sync (service, cancellable, &error)) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); + g_simple_async_result_take_error (simple, error); return; } } @@ -448,8 +443,7 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, cancellable, error ? NULL : &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); return; } } @@ -466,8 +460,7 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, if (error != NULL) { g_warn_if_fail (folder == NULL); - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); + g_simple_async_result_take_error (simple, error); return; } @@ -480,8 +473,7 @@ mail_session_send_to_thread (GSimpleAsyncResult *simple, g_object_unref (folder); if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); + g_simple_async_result_take_error (simple, error); return; } } @@ -615,8 +607,7 @@ exit: /* If we were cancelled, disregard any other errors. */ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); + g_simple_async_result_take_error (simple, error); /* Stuff the accumulated error messages in a GError. */ } else if (error_messages->len > 0) { @@ -843,10 +834,8 @@ mail_session_unsubscribe_folder_thread (GSimpleAsyncResult *simple, e_mail_session_unsubscribe_folder_sync ( session, context->folder_uri, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } gboolean diff --git a/mail/e-mail-session.c b/mail/e-mail-session.c index 45c8e0209c..0687d7561f 100644 --- a/mail/e-mail-session.c +++ b/mail/e-mail-session.c @@ -1249,10 +1249,8 @@ mail_session_get_inbox_thread (GSimpleAsyncResult *simple, context->folder = e_mail_session_get_inbox_sync ( session, context->uid, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } CamelFolder * @@ -1348,10 +1346,8 @@ mail_session_get_trash_thread (GSimpleAsyncResult *simple, context->folder = e_mail_session_get_trash_sync ( session, context->uid, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } CamelFolder * @@ -1448,10 +1444,8 @@ mail_session_uri_to_folder_thread (GSimpleAsyncResult *simple, session, context->uri, context->flags, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } CamelFolder * diff --git a/mail/e-mail-store-utils.c b/mail/e-mail-store-utils.c index 0bf70ae94d..7f978c8b7f 100644 --- a/mail/e-mail-store-utils.c +++ b/mail/e-mail-store-utils.c @@ -54,10 +54,8 @@ mail_store_create_folder_thread (GSimpleAsyncResult *simple, CAMEL_STORE (object), context->full_name, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); } gboolean @@ -191,10 +189,8 @@ mail_store_go_offline_thread (GSimpleAsyncResult *simple, } else em_utils_disconnect_service_sync (service, TRUE, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); camel_operation_pop_message (cancellable); } @@ -270,10 +266,8 @@ mail_store_go_online_thread (GSimpleAsyncResult *simple, CAMEL_OFFLINE_STORE (store), TRUE, cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); camel_operation_pop_message (cancellable); } @@ -343,10 +337,8 @@ mail_store_prepare_for_offline_thread (GSimpleAsyncResult *simple, camel_offline_store_prepare_for_offline_sync ( CAMEL_OFFLINE_STORE (store), cancellable, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); camel_operation_pop_message (cancellable); } diff --git a/modules/composer-autosave/e-autosave-utils.c b/modules/composer-autosave/e-autosave-utils.c index 9c5eaa8236..8d03aaaecc 100644 --- a/modules/composer-autosave/e-autosave-utils.c +++ b/modules/composer-autosave/e-autosave-utils.c @@ -137,9 +137,8 @@ load_snapshot_loaded_cb (GFile *snapshot_file, if (error != NULL) { g_warn_if_fail (contents == NULL); - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); - g_error_free (error); return; } @@ -154,10 +153,9 @@ load_snapshot_loaded_cb (GFile *snapshot_file, g_free (contents); if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); g_object_unref (message); - g_error_free (error); return; } @@ -192,10 +190,8 @@ save_snapshot_splice_cb (GOutputStream *output_stream, g_output_stream_splice_finish (output_stream, result, &error); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); g_object_unref (simple); @@ -220,10 +216,9 @@ save_snapshot_get_message_cb (EMsgComposer *composer, if (error != NULL) { g_warn_if_fail (message == NULL); - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); g_object_unref (simple); - g_error_free (error); return; } @@ -281,10 +276,9 @@ save_snapshot_replace_cb (GFile *snapshot_file, if (error != NULL) { g_warn_if_fail (output_stream == NULL); - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); g_object_unref (simple); - g_error_free (error); return; } @@ -480,10 +474,9 @@ e_composer_save_snapshot (EMsgComposer *composer, if (error != NULL) { g_warn_if_fail (snapshot_file == NULL); - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); g_object_unref (simple); - g_error_free (error); return; } diff --git a/widgets/misc/e-attachment-store.c b/widgets/misc/e-attachment-store.c index 2670369a51..8c808d9731 100644 --- a/widgets/misc/e-attachment-store.c +++ b/widgets/misc/e-attachment-store.c @@ -654,10 +654,8 @@ attachment_store_get_uris_save_cb (EAttachment *attachment, if (error == NULL) g_simple_async_result_set_op_res_gpointer (simple, uris, NULL); - else { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + else + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); @@ -877,10 +875,8 @@ attachment_store_load_ready_cb (EAttachment *attachment, if (error == NULL) g_simple_async_result_set_op_res_gboolean (simple, TRUE); - else { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + else + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); @@ -1158,21 +1154,19 @@ attachment_store_save_cb (EAttachment *attachment, save_context->error = NULL; simple = save_context->simple; - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); attachment_store_save_context_free (save_context); - g_error_free (error); return; } if (error != NULL) { simple = save_context->simple; - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); attachment_store_save_context_free (save_context); - g_error_free (error); return; } diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index ccd135e5a0..4174fe92a5 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -1517,9 +1517,8 @@ attachment_load_check_for_error (LoadContext *load_context, return FALSE; simple = load_context->simple; - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); - g_error_free (error); attachment_load_context_free (load_context); @@ -2021,9 +2020,8 @@ attachment_open_check_for_error (OpenContext *open_context, return FALSE; simple = open_context->simple; - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); - g_error_free (error); attachment_open_context_free (open_context); @@ -2064,10 +2062,8 @@ attachment_open_file (GFile *file, g_simple_async_result_set_op_res_gboolean (simple, success); - if (error != NULL) { - g_simple_async_result_set_from_error (simple, error); - g_error_free (error); - } + if (error != NULL) + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); attachment_open_context_free (open_context); @@ -2324,9 +2320,8 @@ attachment_save_check_for_error (SaveContext *save_context, return FALSE; simple = save_context->simple; - g_simple_async_result_set_from_error (simple, error); + g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); - g_error_free (error); attachment_save_context_free (save_context); |