aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2010-07-14 18:54:01 +0800
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-07-16 23:06:55 +0800
commit138e12ed09d322b9f4ca3892432087e0c8b807ac (patch)
tree6dc15371f4ea58369f40443b8671c2c02374cdb9
parenta0fa7e70bba7a8b085a236fd12c77d1fedf02aaa (diff)
downloadgsoc2013-evolution-138e12ed09d322b9f4ca3892432087e0c8b807ac.tar.gz
gsoc2013-evolution-138e12ed09d322b9f4ca3892432087e0c8b807ac.tar.zst
gsoc2013-evolution-138e12ed09d322b9f4ca3892432087e0c8b807ac.zip
Fix two memory leaks when replying
1: em_utils_reply_to_message() can be passed a newly-created message (from a current selection. It needs to unref it. Which means that when we pass it a message which *isn't* newly-created, we have to obtain a ref of our own. It was that or add a boolean parameter to tell it whether to unref or not. 2: emf_finalize() wasn't unreferencing emf->message -- so when we clone the EMFormat in em_utils_message_to_html() and immediately unreference the clone, a refcount on the message got leaked. Fix emf_finalize() to unref emf->message as presumably it should. This also fixes bug 624285 (using selection when preview is not visible) (cherry picked from commit 8ae4bf802aac4218ebfbe10cae09693ba64c05f3)
-rw-r--r--em-format/em-format.c3
-rw-r--r--mail/e-mail-reader-utils.c14
-rw-r--r--mail/em-composer-utils.c10
3 files changed, 20 insertions, 7 deletions
diff --git a/em-format/em-format.c b/em-format/em-format.c
index 93eab4d61e..49779b012a 100644
--- a/em-format/em-format.c
+++ b/em-format/em-format.c
@@ -117,6 +117,9 @@ emf_finalize (GObject *object)
if (emf->session)
camel_object_unref (emf->session);
+ if (emf->message)
+ camel_object_unref (emf->message);
+
g_hash_table_destroy (emf->inline_table);
em_format_clear_headers(emf);
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index db8da5ca81..b3e6408cf8 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -354,7 +354,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
EMFormatHTMLDisplay *html_display;
GtkWidget *message_list;
CamelMimeMessage *new_message;
- CamelMimeMessage *src_message;
+ CamelMimeMessage *src_message = NULL;
CamelFolder *folder;
GtkHTML *html;
struct _camel_header_raw *header;
@@ -377,6 +377,13 @@ e_mail_reader_reply_to_message (EMailReader *reader,
uid = MESSAGE_LIST (message_list)->cursor_uid;
g_return_if_fail (uid != NULL);
+ if (!gtk_widget_get_mapped (GTK_WIDGET(html)))
+ goto whole_message;
+
+ src_message = CAMEL_MIME_MESSAGE (((EMFormat *) html_display)->message);
+ if (src_message)
+ camel_object_ref(src_message);
+
if (!gtk_html_command (html, "is-selection-active"))
goto whole_message;
@@ -387,8 +394,6 @@ e_mail_reader_reply_to_message (EMailReader *reader,
if (!html_contains_nonwhitespace (selection, length))
goto whole_message;
- src_message =
- CAMEL_MIME_MESSAGE (((EMFormat *) html_display)->message);
new_message = camel_mime_message_new ();
/* Filter out "content-*" headers. */
@@ -410,6 +415,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
CAMEL_MIME_PART (new_message),
selection, length, "text/html");
+ camel_object_unref(src_message);
em_utils_reply_to_message (
folder, uid, new_message, reply_mode, NULL);
@@ -419,7 +425,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
whole_message:
em_utils_reply_to_message (
- folder, uid, NULL, reply_mode, (EMFormat *) html_display);
+ folder, uid, src_message, reply_mode, (EMFormat *) html_display);
}
void
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index d44c0ca584..d1a98b0ff4 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -2194,9 +2194,12 @@ reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *messag
{
struct _reply_data *rd = user_data;
- if (message != NULL)
+ if (message != NULL) {
+ /* get_message_free() will also unref the message, so we need
+ an extra ref for em_utils_reply_to_message() to drop. */
+ camel_object_ref(message);
em_utils_reply_to_message(folder, uid, message, rd->mode, rd->source);
-
+ }
if (rd->source)
g_object_unref(rd->source);
g_free(rd);
@@ -2217,7 +2220,7 @@ reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *messag
*
* If @message is non null, then it is used directly, @folder and @uid
* may be supplied in order to update the message flags once it has
- * been replied to.
+ * been replied to. Note that @message will be unreferenced on completion.
**/
EMsgComposer *
em_utils_reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessage *message, gint mode, EMFormat *source)
@@ -2280,6 +2283,7 @@ em_utils_reply_to_message(CamelFolder *folder, const gchar *uid, CamelMimeMessag
composer_set_body (composer, message, source);
+ camel_object_unref(message);
emcs = g_object_get_data (G_OBJECT (composer), "emcs");
emcs_set_folder_info (emcs, folder, uid, flags, flags);